urbit/docs/pub/doc/hoon/runes/wt/wtcl.md

55 lines
891 B
Markdown
Raw Normal View History

2015-02-18 06:03:21 +03:00
[wutcol, `?:`, %wtcl](#wtcl)
============================
If, then
`?:`, `wutcol`, is a natural hoon that produces `q` if `p` is yes (`&`,
`0`), or `r` if `p` is no (`|`, 1). `?:` is most similar to the
traditional "if" statement, producing the first expression if the
loobean is true. `?:` is the inverse of `?.`.
See also
--------
[wutdot, `?.`, %wtdt](#wtdt)
============================
Produces
--------
Twig: `[%wtcl p=twig q=twig r=twig]`
Sample
------
`p`, `q`, and `r` are [twig]()s.
Tall form
---------
?: p
q
r
Wide form
---------
?:(p q r)
Irregular form
--------------
None
Examples
--------
~zod/try=> ?:((gth 1 2) 1 2)
2
~zod/try=> ?:(?=(%a 'a') %yup %not-a)
%yup
Here we see two common cases of `?:` in the wide form, one uses an
expression `gte` that produces a loobean and the other [`?=`]() to
produce one of its cases.