urbit/base/pub/doc/hoon/runes/kt/ktdt.md

48 lines
789 B
Markdown
Raw Normal View History

2015-02-18 06:03:21 +03:00
[ketdot, `^.`, %ktdt](#ktdt)
============================
Cast to product type
`^.` is a synthetic hoon that casts `q` to the type of `(p q)`. `^.` is
the same as casting `q` to the product type of `p` and comes in handy
when you don't want to run the contents of `p`.
Produces
--------
Twig: `[%ktdt p=twig q=twig]`
Sample
------
`p` is a [twig](). `q` is a [twig]().
Tall form
---------
^. p
q
Wide form
---------
None
Irregular form
--------------
None
Examples
--------
/~zod/try=> =cor |= [~ a=@]
[~ p=a]
changed %cor
/~zod/try=> ^.(cor [~ 97])
[~ p=97]
In this example we create a gate `cor` that takes a cell of `~` and an
atom and produces `[~ p=a]`. Using `^.` we can cast without calling
`cor` and produce the same result.