urbit/pub/docs/dev/hoon/runes/wt/wtdt.md

54 lines
839 B
Markdown
Raw Normal View History

wutdot, `?.`, %wtdt
2015-02-18 06:03:21 +03:00
============================
If, else
2015-11-07 21:49:34 +03:00
`?.`is a synthetic rune that produces `r` if `p` is yes (`&`, `0`), or
2015-02-18 06:03:21 +03:00
`q` if `p` is no (`|`, 1). `?.` is sort of like "if not", producing the
second expression if the loobean is true. `?.` is the inverse of `?:`.
See also
--------
wutcol, `?:`, %wtcl
2015-02-18 06:03:21 +03:00
============================
Produces
--------
Twig: `[%wtdt 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)
1
~zod/try=> ?.(?=(%a 'a') %not-a %yup)
%yup
Here we see two common cases of `?.` in the wide form, one uses an
expression `gth` that produces a loobean and the other [`?=`]() to
produce one of its cases.