on master help sign in
Various fixes and improvements.
commit3fee830e4aeee09343789ac524f67590d1baa810 authorC. Guy Yarvin <cgyarvin@gmail.com> dateSun 17 Apr 2016, 21:55 (11 years ago) parent4191825
38 files changed+731−750
docs/programming/advanced/catalog/bar-core/cab-door.md+1−1 docs/programming/advanced/catalog/bar-core/cen-core.md+1−1 docs/programming/advanced/catalog/bar-core/dot-trap.md+1−1 docs/programming/advanced/catalog/bar-core/hep-loop.md+1−1 docs/programming/advanced/catalog/bar-core/tar-gill.md+9−7 docs/programming/advanced/catalog/bar-core/tis-gate.md+3−1 docs/programming/advanced/catalog/buc-mold/cab-shoe.md+25−11 docs/programming/advanced/catalog/buc-mold/cen-book.md+31−10 docs/programming/advanced/catalog/buc-mold/col-bank.md+27−12 docs/programming/advanced/catalog/buc-mold/hep-lamb.md+26−6 docs/programming/advanced/catalog/buc-mold/ket-bush.md+19−6 docs/programming/advanced/catalog/buc-mold/pat-claw.md+18−1 docs/programming/advanced/catalog/buc-mold/tis-coat.md+21−7 docs/programming/advanced/catalog/buc-mold/wut-pick.md+28−6 docs/programming/advanced/catalog/cen-call/buc-bunt.md docs/programming/advanced/catalog/cen-call/cab-keep.md−74 docs/programming/advanced/catalog/cen-call/dot-lace.md+15−44 docs/programming/advanced/catalog/cen-call/hep-call.md+29−32 docs/programming/advanced/catalog/cen-call/ket-calq.md+15−21 docs/programming/advanced/catalog/cen-call/lus-calt.md+14−43 docs/programming/advanced/catalog/cen-call/sig-open.md+20−65 docs/programming/advanced/catalog/cen-call/tar-bake.md−48 docs/programming/advanced/catalog/cen-call/tis-make.md+30−55 docs/programming/advanced/catalog/misc/buc-bunt.md+5 docs/programming/advanced/catalog/wut-test/bar-or.md+23−23 docs/programming/advanced/catalog/wut-test/col-if.md+36−12 docs/programming/advanced/catalog/wut-test/dot-lest.md+32−17 docs/programming/advanced/catalog/wut-test/gal-deny.md+22−10 docs/programming/advanced/catalog/wut-test/gar-sure.md+21−9 docs/programming/advanced/catalog/wut-test/hep-case.md+49−52 docs/programming/advanced/catalog/wut-test/ket-ifcl.md+30−34 docs/programming/advanced/catalog/wut-test/lus-deft.md+41−59 docs/programming/advanced/catalog/wut-test/pam-and.md+23−17 docs/programming/advanced/catalog/wut-test/pat-ifat.md+26−18 docs/programming/advanced/catalog/wut-test/sig-ifno.md+26−15 docs/programming/advanced/catalog/wut-test/tis-fits.md+35−14 docs/programming/advanced/catalog/wut-test/zap-not.md+27−16 docs/programming/twig/mold.md+1−1
docs/programming/advanced/catalog/bar-core/cab-door.md+1−1
@@ -4,7 +4,7 @@ sort: 5
44
55# `:door, |_, "buccab", {$door p/moss q/(map term foot)}`
66
7−Make a door, a many-armed core with a sample.
7+Form a door, a many-armed core with payload `{sample context}`.
88
99## Expands to
1010
docs/programming/advanced/catalog/bar-core/cen-core.md+1−1
@@ -4,7 +4,7 @@ sort: 1
44
55# `:core, |%, "barcen", {$core p/(map term foot)}`
66
7−Make a core, a code-data pair with functional attributes.
7+Form a core `{battery payload}` with subject as the payload.
88
99## Produces
1010
docs/programming/advanced/catalog/bar-core/dot-trap.md+1−1
@@ -4,7 +4,7 @@ sort: 3
44
55# `:trap. |., "bardot", {$trap p/twig}`
66
7−Make a trap, a core with no sample and one arm `$`.
7+Form a trap, a core with one arm `$`.
88
99## Expands to
1010
docs/programming/advanced/catalog/bar-core/hep-loop.md+1−1
@@ -4,7 +4,7 @@ sort: 4
44
55# `:loop, |-, "barhep", {$loop p/twig}`
66
7−Make a trap and kick it.
7+Form a trap (a core with one dry arm `$`) and kick it.
88
99## Expands to
1010
docs/programming/advanced/catalog/bar-core/tar-gill.md+9−7
@@ -4,7 +4,7 @@ sort: 6
44
55# `:gill, |*, "bartar", {$gill p/moss q/twig}`
66
7−Make a wet gate, a generically typed Hoon function.
7+Form a gill, a wet one-armed core with payload `{sample context}`.
88
99## Expands to
1010
@@ -23,13 +23,12 @@ Regular: *2-fixed*.
2323## Discussion
2424
2525In a normal (dry) gate, your argument is converted into the
26−sample type. In a generic (wet) gate, your argument type passes
27−through the function, rather as if it was a macro (there is still
28−only one copy of the code, however).
26+sample type. In a generic (wet) gate or gill, your argument type
27+passes through the function, rather as if it was a macro (there
28+is still only one copy of the code, however).
2929
30−Genericity is a powerful and dangerous tool. Use wet gates only
31−if you think you know what you're doing. They are generally used
32−for system infrastructure, not user-level code.
30+Genericity is a powerful and dangerous tool. Use gills only if
31+you think you know what you're doing.
3332
3433## Examples
3534
@@ -43,3 +42,6 @@ Wet and dry gates in a nutshell:
4342~zod:dojo> (bar %cat %dog)
4443[%dog %cat]
4544```
45+
46+The dry gate does not preserve the span of `a` and `b`; the wet
47+gate does.
docs/programming/advanced/catalog/bar-core/tis-gate.md+3−1
@@ -4,7 +4,7 @@ sort: 2
44
55# `:gate, |=, "bartis", {$gate p/moss q/twig}`
66
7−Make a gate, a Hoon function.
7+Form a gate, a dry one-armed core with payload `{sample context}`.
88
99## Expands to
1010
@@ -20,6 +20,8 @@ Make a gate, a Hoon function.
2020
2121Regular: *2-fixed*.
2222
23+## Discussion
24+
2325## Examples
2426
2527A trivial gate:
docs/programming/advanced/catalog/buc-mold/cab-shoe.md+25−11
@@ -1,26 +1,40 @@
1−# `:shoe, $_, "buccab", {$shoe p/twig}`
1+---
2+sort: 1
3+---
24
3−Type as a single example.
5+# `:shoe, $_, "buccab", {$shoe p/twig}`
46
5−Product: a mold whose product is always `p`.
7+Form a mold which normalizes to an example.
68
7−Regular form: *1-fixed*.
9+## Expands to
810
9−Irregular form:
1011```
11−_%foo :shoe(%foo)
12+:gate *
13+p
1214```
1315
14−Example:
16+## Syntax
17+
18+Regular: *1-fixed*.
19+
20+Irregular: `_foo` is `:shoe(foo)`.
21+
22+## Discussion
23+
24+A shoe discards the sample it's supposededly normalizing, and
25+produces its example instead.
26+
27+## Examples
28+
1529```
16−~zod:dojo> =a :shoe([%foobar %moobaz])
30+~zod:dojo> =foo :shoe([%foobar %moobaz])
1731
18−~zod:dojo> (a %foo %bar)
32+~zod:dojo> (foo %foo %bar)
1933[%foobar %moobaz]
2034
21−~zod:dojo> `a`[%foobar %moobaz]
35+~zod:dojo> `foo`[%foobar %moobaz]
2236[%foobar %moobaz]
2337
24−~zod:dojo $:a
38+~zod:dojo $:foo
2539[%foobar %moobaz]
2640```
docs/programming/advanced/catalog/buc-mold/cen-book.md+31−10
@@ -1,21 +1,42 @@
1−# `:book, $%, "buctis", {$book p/(list moss)}`
1+---
2+sort: 2
3+---
24
3−Tagged union
5+# `:book, $%, "buctis", {$book p/(list {{aura @} moss})}`
46
5−Product: a mold producing the tagged union of the molds in
6−`p`, all of which must be of the form `:bank(stem bulb)`, where
7−`stem` is an atomic mold.
7+Form a mold which normalizes a union distinguished by a head atom.
88
9−Regular form: *running*.
9+## Normalizes to
1010
11−Examples:
11+For any item `i` in `p`, a cell whose head is the atom `q.p.i.p`,
12+and whose tail recognizes `q.i.p`.
13+
14+Void if `p` is empty.
15+
16+## Defaults to
17+
18+For the first item `i` in `p`, the cell `[q.p.i.p $:q.i.p]`.
19+Crashes if `p` is empty.
20+
21+## Syntax
22+
23+Regular form: *2-running*.
24+
25+## Discussion
26+
27+A book is a tagged union, an extremely common data model.
28+
29+Each item in a book is called a "page." Make sure the first page
30+in the book terminates, or the default will be an infinite loop!
31+
32+## Examples
1233
1334```
14−~zod:dojo> =a :book({$foo p/@ud q/@ud} {$bar p/@ud})
35+~zod:dojo> =foo :book({$foo p/@ud q/@ud} {$bar p/@ud})
1536
16−~zod:dojo> (a [%bar 37])
37+~zod:dojo> (foo [%bar 37])
1738[%bar p=37]
1839
19−~zod:dojo> $:a
40+~zod:dojo> $:foo
2041[%foo p=0 q=0]~
2142```
docs/programming/advanced/catalog/buc-mold/col-bank.md+27−12
@@ -1,26 +1,41 @@
1+---
2+sort: 3
3+---
4+
15# `:bank, $:, "buccol", {$bank p/(list moss)}`
26
3−Tuple of molds
7+Form a mold which recognizes a tuple.
48
5−Product: a mold which applies the tuple `p` to its sample.
9+## Normalizes
610
7−Regular form: *running*.
11+The tuple the length of `p`, normalizing each item, defaulting
12+where the tuple does not match.
813
9−Irregular form:
10−```
11−{a b c} :bank(a b c)
12−```
14+Void if `p` is empty.
15+
16+## Defaults to
17+
18+The tuple the length of `p`, defaulting each items.
19+
20+Crashes if `p` is empty.
21+
22+## Syntax
23+
24+Regular: *running*.
25+
26+Irregular: `{a b c}` is `:bank(a b c)`.
27+
28+## Examples
1329
14−Example:
1530```
16−~zod:dojo> =a :bank(p/@ud q/@tas)
31+~zod:dojo> =foo :bank(p/@ud q/@tas)
1732
18−~zod:dojo> (a 33 %foo)
33+~zod:dojo> (foo 33 %foo)
1934[p=33 q=%foo]
2035
21−~zod:dojo> `a`[33 %foo]
36+~zod:dojo> `foo`[33 %foo]
2237[p=33 q=%foo]
2338
24−~zod:dojo> $:a
39+~zod:dojo> $:foo
2540[p=0 q=%$]
2641```
docs/programming/advanced/catalog/buc-mold/hep-lamb.md+26−6
@@ -1,15 +1,35 @@
1+---
2+sort: 4
3+---
4+
15# `:lamb, $-, "buchep", {$lamb p/moss q/moss}`
26
3−Function type.
7+Form a mold which normalizes to an example gate.
8+
9+## Expands to
10+
11+```
12+:shoe
13+:iron
14+:gate p
15+$:q
16+```
17+
18+## Syntax
19+
20+Regular: *2-fixed*.
21+
22+## Discussion
423
5−Product: a mold producing a gate accepting
24+Since a lamb is a shoe, it is not useful for normalizing, just
25+for its signature. In particular, the existence of lambs does
26+let us send gates or other cores over the network!
627
7−Regular form: *2-fixed*.
28+## Examples
829
9−Example:
1030```
11−~zod:dojo> =a :lamb($foo $bar)
31+~zod:dojo> =foo :lamb($foo $bar)
1232
13−~zod:dojo> ($:a %foo)
33+~zod:dojo> ($:foo %foo)
1434%bar
1535```
docs/programming/advanced/catalog/buc-mold/ket-bush.md+19−6
@@ -1,13 +1,26 @@
1−# `:bush, $&, "bucpam", {$bush p/moss q/moss}`
1+---
2+sort: 5
3+---
24
3−Union of two cells: one w/cellular head & other w/atomic head.
5+# `:bush, $^, "bucket", {$bush p/moss q/moss}`
46
5−Product: a mold which applies `p` if the head of its sample
6−is a cell, `q` if the head of its sample is a cell.
7+Form a mold which normalizes a union distinguished by head depth.
78
8−Regular form: *2-fixed*.
9+## Normalizes to
10+
11+Default, if the sample is an atom; `p`, if the head of the sample
12+is an atom; `q` otherwise.
13+
14+## Defaults to
15+
16+The default of `p`.
17+
18+## Syntax
19+
20+Regular: *2-fixed*.
21+
22+## Examples
923
10−Example:
1124```
1225~zod:dojo> =a :book({$foo p/@ud q/@ud} {$bar p/@ud})
1326
docs/programming/advanced/catalog/buc-mold/pat-claw.md+18−1
@@ -1,6 +1,23 @@
1+---
2+sort: 6
3+---
4+
15# `:claw, $@, "bucpat", {$claw p/moss q/moss}`
26
3−Type: either an atom or a cell.
7+Form a mold which normalizes a union distinguished by depth.
8+
9+## Normalizes to
10+
11+Default, if the sample is an atom; `p`, if the head of the sample
12+is an atom; `q` otherwise.
13+
14+## Defaults to
15+
16+The default of `p`.
17+
18+## Syntax
19+
20+Regular: *2-fixed*.
421
522Product: a mold which applies `p` if its sample is an atom,
623`q` if its sample is a cell.
docs/programming/advanced/catalog/buc-mold/tis-coat.md+21−7
@@ -1,17 +1,31 @@
1−# `:coat, $=, "buctis", {$coat p/@tas q/moss}`
1+---
2+sort: 7
3+---
24
3−Add variable name
5+# `:coat, $=, "buctis", {$coat p/@tas q/moss}`
46
5−Product: a mold which puts the label `p` on the mold `q`.
7+Form a mold which wraps a face around another mold.
68
7−Regular form: *2-fixed*.
9+## Expands to
810
9−Irregular form:
1011```
11−a/b :coat(a b)
12+:gate *
13+:name(p :call(q +6))
1214```
1315
14−Examples:
16+## Syntax
17+
18+Regular: *2-fixed*.
19+
20+Irregular: `foo/bar` is `:coat(foo bar)`.
21+
22+## Discussion
23+
24+Note that the Hoon compiler is at least slightly clever about
25+compiling molds, and almost never has to actually put in a gate
26+layer (as seen in the expansion above) to apply a coat.
27+
28+## Examples
1529
1630```
1731~zod:dojo> =a :coat(p $foo)
docs/programming/advanced/catalog/buc-mold/wut-pick.md+28−6
@@ -1,16 +1,38 @@
1+---
2+sort: 8
3+---
4+
15# `:pick, $?, "bucwut", {$? p/(list moss)}`
26
3−Generalized type union.
7+Form a mold which normalizes a general union.
8+
9+## Normalizes to
10+
11+The first item in `p` which normalizes the sample to itself;
12+otherwise, default.
13+
14+Void, if `p` is empty.
15+
16+## Defaults to
17+
18+The first item in `p`.
19+
20+## Syntax
21+
22+Regular: *running*.
23+
24+Irregular: `?(%foo %bar)` is `$?(%foo %bar)`.
425
5−Product: a mold which tries each of the alternatives in `p`.
26+## Discussion
627
7−Note: Use `:pick` only if none of `:book` (`$%`), `:claw` (`$@`) or `:bush` (`$&`) applies.
28+For a union of atoms, a pick is fine. For more complex nouns,
29+always try to use a book, claw or bush, at least if you expect
30+your mold to be used as a normalizer.
831
9−Regular form: *running*.
32+## Examples
1033
11−Example:
1234```
13−~zod:dojo> =a :pick($foo $bar $baz)
35+~zod:dojo> =a ?($foo $bar $baz)
1436
1537~zod:dojo> (a %baz)
1638%baz
docs/programming/advanced/catalog/cen-call/buc-bunt.mddeleted

No changes to the content.

docs/programming/advanced/catalog/cen-call/cab-keep.mddeleted−74
@@ -1,74 +0,0 @@
1−`%_ cencab`
2−===========
3−
4−`%=`, but product cast to `p`.
5−
6−The same as [`%=`](), except for that the product is cast
7−back to the type of `p`. Evaluates `p` with the changes specified in `q`, then casts the product back to the type of `p`. `%_` is used to change a batch of [`++wing`]()s all at once, ensuring that the resulting product is type checked.
8−
9−You generally want to use `%_` unless you are intentionally trying to change the type.
10−
11−Produces
12−--------
13−
14−Twig: `[%cncb p=wing q=tram]`
15−
16−Accepts
17−-------
18−
19−`p` is a `++wing`, a list of [`++limb`]()s. `q` is a [`++tram`](), a
20−list of key value pairs of [`++wing`]()s to twigs.
21−
22−Tall form
23−---------
24−
25− %_ p
26− p.i.q q.i.q
27− p.i.t.q q.i.t.q
28− ==
29−
30−Wide form
31−---------
32−
33− %_(p p.i.q q.i.q, p.i.t.q q.i.t.q)
34−
35−Examples
36−--------
37−
38− /~zod:dojo> =a [b=1 c=2 d=3]
39− new var %a
40− /~zod:dojo> %_(a b (add 3 b.a), c (add 3 c.a), d (add 3 d.a))
41− [b=4 c=5 d=6]
42−
43−Here we're using `%_` to add 3 to all of the values inside of our shell
44−variable `a`.
45−
46− /~zod:dojo> =a [b='odors' c='twigs' d='molds']
47− changed %a
48− /~zod:dojo> %_(a b c.a, c d.a, d b.a)
49− [b='twigs' c='molds' d='odors']
50−
51−In this case we're using `%_` to swap the values of the faces in `a`.
52−
53− /~zod:dojo> =+ a=1
54− =+ z=|=(b=@ (add a b))
55− (z 1)
56− 2
57− /~zod:dojo> =+ a=1
58− =+ z=|=(b=@ (add a b))
59− (%_(z a 100) 1)
60− 101
61−
62−At first we set up a simple function `z` with a variable, `a` in its
63−context. Subsequently we use `%_` to change the value of `a` within the
64−context of `z` and compute the output again.
65−
66− =+(a=[var1=1 var2=2] %_(a var1 [3 4]))
67− ...
68− type-fail
69− ford: build failed
70−
71−The example above fails because the type of the result is a cell
72−of a cell and an atom (`[^ @]`) does not fit within the type of
73−`a` (`[@ @]`).
74−
docs/programming/advanced/catalog/cen-call/dot-lace.md+15−44
@@ -1,53 +1,24 @@
1−`%. cendot`
2−===========
1+---
2+sort: 4
3+---
34
4−Inverted function call.
5+# `:lace, %., "cendot", {$lace p/seed q/seed}`
56
6−Inverts the order of [`%-`](), so the argument is the first
7−element and the second element is the function. Exists primarily
8−for code readability and organization. See the [backstep
9−section]() for more information.
7+Call a gate (function), reversed.
108
11−Produces
12−--------
9+## Expands to
1310
14−Twig: `[%cndt p=twig q=twig]`
11+`:call(q p)`.
1512
16−Accepts
17−-------
13+## Syntax
1814
19−`p` and `q` are [`++twig`]()s. `p` is the argument and `q` is the function (that's a twig).
15+Regular: *2-fixed*.
2016
21−Tall form
22−---------
17+## Examples
2318
24− %. p
25− q
19+```
20+~zod:dojo> =add-triple |=({a/@ b/@ c/@} :(add a b c))
21+~zod:dojo> %.([1 2 3] add-triple)
22+6
23+```
2624
27−Wide form
28−---------
29−
30− %.(p q)
31−
32−Examples
33−--------
34−
35− /~zod:dojo> (dec 42)
36− 41
37− ~zod:dojo> %.(42 dec)
38− 41
39−
40−In the most straightforward case `%.` allows us to reverse the order of
41−arm and arguments.
42−
43− /~zod:dojo> %.
44− %+ add
45− %+ mul 2 20
46− 2
47− dec
48− 41
49−
50−Here we add `2` to the product of `2` and `20`, and use `%.` to
51−decrement our result. As you can see, `%.` is most useful for code
52−organization, when you need to compute intermediate products for your
53−final result.
docs/programming/advanced/catalog/cen-call/hep-call.md+29−32
@@ -1,46 +1,43 @@
1−`%- cenhep`
2−===========
1+---
2+sort: 3
3+---
34
4−Call function w/ one argument.
5+# `:call, %-, "cenhep", {$call p/seed q/seed}`
56
6−Call function with one argument. Has an irregular wideform syntax: `(function[arg0 arg1...])`, which can takes n arguments enclosed within the `()`. Note
7−that one can also pass a tall form (or wide form) function called with `%-` a tuple with `n` elements for functions that require more than one argument.
7+Call a gate (function).
88
9−%- is a synthetic rune that that pulls $ from the door p with its sample set to [%cltr q]. %- in both its tall and wide forms is like a function call with one argument.
9+## Expands to
1010
11−Produces
12−--------
11+`:open($ p q)`.
1312
14−Twig: `[%cnhp p=twig q=tusk]`
13+## Syntax
1514
16−Accepts
17−-------
15+Regular: *2-fixed*.
1816
19−`p` is a [++twig](), most commonly a function, and in tall form `q` is a twig. In irregular wide form, `q` is a [`++tusk`](), a list of twigs.
17+Irregular: `(a)` is `$:a`; `(a b c d)` is `:call(a [b c d])`.
2018
21−Tall form
22−---------
19+## Discussion
2320
24− %- p
25− q
26− ==
21+`$call` is a function call; `p` is the function (`gate`), `q` the
22+argument. `$call` is a special case of `$open`, and a gate is a
23+special case of a door.
2724
28−Wide form
29−---------
25+In a gate, the modified core has only one anonymous arm; in a
26+door it gets a full battery. Intuitively, a gate defines one
27+algorithm it can compute upon its sample, `+6`. A door defines
28+many such algorithms.
3029
31− %-(p q)
30+In classical languages, doors correspond to groups of functions
31+with the same argument list, or at least sharing a prefix. In
32+Hoon, this shared sample is likely to be pulled into a door.
3233
33−Irregular form
34−--------------
34+## Examples
3535
36− (p q)
37−
38−Examples
39−--------
40−
41− > %-(dec 4)
42− 3
43−
44− > (add 2 2)
45− 4
36+```
37+~zod:dojo> =add-triple |=({a/@ b/@ c/@} :(add a b c))
38+~zod:dojo> (add-triple 1 2 3)
39+6
40+~zod:dojo> %-(add-triple [1 2 3])
41+6
42+```
4643
docs/programming/advanced/catalog/cen-call/ket-calq.md+15−21
@@ -1,29 +1,23 @@
1−`%^ cenket`
2−===========
1+---
2+sort: 6
3+---
34
4−Call function w/ three arguments.
5+# `:calq, %^, "cenket", {$calq p/seed q/seed r/seed s/seed}`
56
6−Calls the one arm ([$]()) from the [door]() `p` with its [sample]() set to `[%cntr q r s]`. `%^` in the most common case simply calls `p` with `q`, `r`and `s` as its arguments.
7+Call a gate (function), with a triple sample.
78
8−Produces
9−--------
9+## Expands to
1010
11−Twig: `[%cnkt p=twig q=twig r=twig s=twig]`
11+`:call(p [q r s])`.
1212
13−Accepts
14−-------
13+## Syntax
1514
16−`p` is a [`++twig`](), most commonly a function. The arguments `q`, `r` and `s` are twigs as well.
15+Regular: *4-fixed*.
1716
18−Tall form
19−---------
17+## Examples
2018
21− %^ p
22− q
23− r
24− s
25−
26−Wide form
27−---------
28−
29− %^(p q r s)
19+```
20+~zod:dojo> =add-triple |=({a/@ b/@ c/@} :(add a b c))
21+~zod:dojo> %^(add-triple 1 2 3)
22+6
23+```
docs/programming/advanced/catalog/cen-call/lus-calt.md+14−43
@@ -1,52 +1,23 @@
1−`%+ cenlus`
2−===========
1+---
2+sort: 5
3+---
34
4−Call function w/ two arguments.
5+# `:calt, %+, "cenlus", {$calt p/seed q/seed r/seed}`
56
6−Calls the one arm ([$]()) from the [door]() `p` with its [sample]() set to `[%cntr q r]`.
7+Call a gate (function), with a cell sample.
78
9+## Expands to
810
9−Produces
10−--------
11+`:call(p [q r])`.
1112
12−Twig: `[%cnls p=twig q=twig r=twig]`
13+## Syntax
1314
14−Accepts
15−-------
15+Regular: *3-fixed*.
1616
17−`p` is a [`++twig`](), most commonly a function. The arguments `q` and `r` are twigs as well
17+## Examples
1818
19−Tall form
20−---------
19+```
20+~zod:dojo> =add-triple |=({a/@ b/@ c/@} :(add a b c))
21+~zod:dojo> %+(add-triple 1 [2 3])
22+6
2123
22− %+ p
23− q
24− r
25−
26−Wide form
27−---------
28−
29− %+(p q r)
30−
31−Irregular form
32−--------------
33−
34−None
35−
36−Examples
37−--------
38−
39− /~zod:dojo> =a |= [b=@ c=@]
40− (add b c)
41− new var %a
42− /~zod:dojo> %+ a
43− 2
44− 1
45− 3
46− /~zod:dojo> %+(a 2 3)
47− 5
48−
49−First we set a shell variable `a` to be a function that takes two arguments
50−and produces their sum. Then we use `%+` to pass values to our gate.
51−`%+` is most useful for code organization, when you need to compute
52−intermediate products for your final computation.
docs/programming/advanced/catalog/cen-call/sig-open.md+20−65
@@ -1,77 +1,32 @@
1−`%~ censig`
2−===========
1+---
2+sort: 2
3+---
34
4−Call arm in door w/ argument.
5+# `:open, %~, "censig", {$cnsg p/wing q/twig r/twig}
56
6−Evaluates the expression addressed at `p` within core
7−`q` whose input data ([sample]()) is set to `r`. Used frequently with
8−[`++map`]()s and [`++set`]()s, etc.
7+## Expands to
98
10−Produces
11−--------
9+```
10+:rap(p :make(q +6 r))
11+```
1212
13−Twig: `[%cnsg p=wing q=twig r=twig]`
13+## Syntax
1414
15−Accepts
16−-------
15+Regular: *3-fixed*.
1716
18−`p` is a [`wing`](). `q` and `r` are [`twig`]()s.
17+Irregular: `~(a b c)` is `%~(a b c)`; `~(a b c d e)` is `%~(a b
18+[c d e])`.
1919
20−Tall form
21−---------
20+## Discussion
2221
23− %~ p
24− q
25− r
22+`:open` is the general case of a function call, `:call`. In
23+both, we replace the sample (`+6`) of a core. In `:call` the
24+core is a gate and we
2625
27−Wide form
28−---------
26+Most languages do not have cores, doors, or `:open`. "Just
27+learn to step outside your linear, Western way of thinking."
2928
30− %~(p q r)
29+## Examples
3130
32−Irregular form
33−--------------
31+See [`:door`](../bar-core/cab-door).
3432
35− ~(p q r)
36−
37−Examples
38−--------
39−
40− /~zod:dojo> =door |_ a=@
41− ++ fort |= b=@
42− (add b a)
43− --
44− new var %door
45− /~zod:dojo> (~(fort door 10) 1)
46− 11
47− /~zod:dojo> (~(fort door 10) 10)
48− 20
49−
50−Here we create a door using [`|_`]() as the shell variable `door` which
51−takes an atom. `door` has one arm `fort`, a gate, which takes an atom as
52−well and produces the sum. We use the irregular form of `%~` to set the
53−sample in `door`, and call it.
54−
55− /~zod:dojo> =a (mo (limo [['a' 1] ['b' 2] ~]))
56− changed %a
57− /~zod:dojo> a
58− {[p='a' q=1] [p='b' q=2]}
59− /~zod:dojo> (~(get by a) 'b')
60− [~ 2]
61−
62−In this case we create a simple map, `a` using [`++mo`]() and
63−['++limo'](). Then we use [`++get:by`]() to pull a value out of it by
64−first setting the sample of [`++by`]() to `a` and pulling `get` using
65−the irregular form of `%~`. Passing `'b'` to the resulting gate produces
66−the value of `'b'` in our map.
67−
68−This is a very common use of `%~`. Most of the container engines in
69−`hoon.hoon` use doors with samples, so we use `%~` to set the sample and
70−pull the door to produce a gate we can pass data to.
71−
72− =door |_ a=@
73− ++ fort |= b=@
74− (add b a)
75− --
76− (%~(fort door 10) 1)
77− 11
docs/programming/advanced/catalog/cen-call/tar-bake.mddeleted−48
@@ -1,48 +0,0 @@
1−`%* centar`
2−===========
3−
4−`%~` call arm from door w/ context changes.
5−
6−The same as `%~` but can make changes anywhere in the context, not just within the input data (sample). Evaluates the expression `p` within core `q` with changes `r` to the context.
7−
8−Produces
9−--------
10−
11−Twig: `[%cntr p=wing q=twig r=tram]`
12−
13−Accepts
14−-------
15−
16−`p` is a [++wing](). `q` is a [++twig](). `r` is a [++tram]().
17−
18−Tall form
19−---------
20−
21− %* p q
22− p.i.r q.i.r
23− p.i.t.r q.i.t.r
24− ==
25−
26−Wide form
27−---------
28−
29− %*(p q p.i.r q.i.r, p.i.t.r q.i.t.r)
30−
31−Examples
32−--------
33−
34− /~zod:dojo> =a 42
35− new var %a
36− /~zod:dojo> =b |%
37− ++ mult (mul 2 a)
38− --
39− new var %b
40− /~zod:dojo> mult.b
41− 84
42− /~zod:dojo> %*(mult b a 2)
43− 4
44−
45−Here we add a variable `a` to our context, and a door `b` with a wing
46−`++mult`that depends on `a`. Calling `++mult` produces `84`, and we can
47−use `%*` to replace `a` in the context of `mult.b` with `2` to simply
48−produce `4`.
docs/programming/advanced/catalog/cen-call/tis-make.md+30−55
@@ -1,68 +1,43 @@
1−`%= centis`
2−===========
1+---
2+sort: 1
3+---
34
4−Eval `p` w/ changes.
5+# `:make, %=, centis, {$make p/wing q/(list (pair wing seed))}`
56
6−Evaluates `p` with the changes specified in `q`, where `q` is a list of addresses ([`++wing`]())s followed by the values that will replace whatever value currently lies at that address. Makes the changes all at once to ensure that the product type is checked.
7+Take a wing (attribute path) with changes.
78
8−Like `%-`, `%=` has an addtional, irregular wifeform syntax that is frequently
9−used: `a(p q.p, q p.a)`, where `a` is the code to be executed with the changes
10−specified within the `()`.
9+## Produces
1110
12−Produces
13−--------
11+`p`, modified by the change list `q`.
1412
15−Twig: `[%cnts p=wing q=tram]`
13+If `p` resolves to a leg, `q` is a list of changes to that leg.
14+If `p` resolves to an arm, `q` is a list of changes to the core
15+containing that arm. We compute the arm on the modified core.
1616
17−Accepts
18−-------
17+## Syntax
1918
20−`p` is a `++wing`. `q` is a [++tram]().
19+Regular: *1-fixed*, then *jogging*.
2120
22−Tall form
23−---------
21+Irregular: `foo(x 1, y 2, z 3)` is `:make(foo x 1, y 2, z 3)`.
2422
25− %= p
26− p.i.q q.i.q
27− p.i.t.q q.i.t.q
28− ==
23+## Discussion
2924
30−Wide form
31−---------
25+Note that `p` is a wing, not a twig. Knowing that a function
26+call `(foo bar)` involves making `foo`, replacing its sample
27+at slot `+6` with `bar`, and taking the `$` limb, you might think
28+`(foo bar)` would mean `:(make foo +6 bar)`.
3229
33− %=(p p.i.q q.i.q, p.i.t.q q.i.t.q)
30+But it's actually `:pin(foo :(make $ +2 +6 bar))`. Even if `foo`
31+is a wing, we would just be mutating `+6` within the core that
32+defines the `foo` arm. Instead we want to modify the *product*
33+of `foo` -- the gate -- so we have to pin it into the subject.
3434
35−Irregular form
36−--------------
35+## Examples
3736
38− p(p.i.q q.i.q, p.i.t.q q.i.t.q)
39−
40−Examples
41−--------
42−
43− /~zod:dojo> =+ a=[p=5 q=6]
44− a(p 2)
45− [p=2 q=6]
46−
47−In this example we are using the irregular form of `%=` to replace `p`
48−in `a`.
49−
50− /~zod:dojo> =+ a=[p=1 q=2 r=3 s=4]
51− a(p 5, q 6, r 7, s 8)
52− [p=5 q=6 r=7 s=8]
53−
54−Here we show how you can replace multiple faces at once. We start with a
55−new `a` and replace all of its values with the irregular form of `%=`.
56−
57− /~zod:dojo> =+ step=0
58− =+ leng=10
59− =+ valu=0
60− |-
61− ?: =(step leng)
62− valu
63− $(valu (mul 2 valu), step +(step))
64− 1.024
65−
66−In this case we create a simple loop, using [`|-`](). To recurse, we use
67−`%=` with [`$`](), the empty name — our `|-` — replacing our `valu` with
68−`(mul 2 valu)` and `step` with `+(step)`.
37+```
38+~zod:dojo> =foo [p=5 q=6]
39+~zod:dojo> foo(p 42)
40+[p=42 q=6]
41+~zod:dojo> foo(+3 99)
42+[p=5 99]
43+```
docs/programming/advanced/catalog/misc/buc-bunt.mdnew file+5
@@ -0,0 +1,5 @@
1+---
2+sort: 7
3+---
4+
5+`:bunt`, {$bunt p/moss}
docs/programming/advanced/catalog/wut-test/bar-or.md+23−23
@@ -1,30 +1,30 @@
1−# `:or`, `?|`, "wutbar" `{$or p/(list twig)}`
1+---
2+sort: 9
3+---
24
3−Logical 'or'.
5+# `:or`, `?|`, "wutbar" `{$or p/(list seed)}`
46
5−Computes the logical 'or' operation on a list of boolean expressions `p`.
7+Logical or.
68
7−Regular form: *running*
9+## Expands to
810
9−Irregular form:
11+```
12+:ifno p
13+ |
14+:if i.p
15+ &
16+:moar(p t.p)
17+```
1018
11−`?(a b c) ?|(a b c)`
19+## Syntax
1220
13−Examples:
21+Regular: *running*.
1422
15− ~zod:dojo> ?|(& |)
16− %.y
17− ~zod:dojo> |(& |)
18− %.y
19− ~zod:dojo> |(| |)
20− %.n
21− ~zod:dojo> (gth 2 1)
22− %.y
23− ~zod:dojo> |((gth 2 1) |)
24− %.y
25− ~zod:dojo> |((gth 1 2) |)
26− %.n
27− ~zod:dojo> |((gth 2 1) &)
28− %.y
29− ~zod:dojo> |((gth 1 2) &)
30− %.y
23+Irregular: `|(foo bar baz)` is `?|(foo bar baz)`.
24+
25+## Examples
26+
27+```
28+~zod:dojo> |(=(6 42) =(42 42))
29+%.y
30+```
docs/programming/advanced/catalog/wut-test/col-if.md+36−12
@@ -1,18 +1,42 @@
1−# `if`, `?:`, "wutcol" `{$if p/twig q/twig r/twig}`
1+---
2+sort: 1
3+---
24
3−If-then-else.
5+# `:if, ?:, "wutcol", `{$if p/seed q/seed r/seed}`
46
5−If `p` evaluates to true, then `q`. Else, `e`.
7+Branch on a boolean test.
68
7−Regular form: *3-fixed*
9+## Produces
810
9−Examples:
11+If `p` produces yes, then `q`. If `p` produces no, `r`.
12+If `p` is not a boolean, compiler yells at you.
1013
11− ~zod:dojo> ?:((gth 1 2) 1 2)
12− 2
13− ~zod:dojo> ?:(?=(%a 'a') %yup %not-a)
14− %yup
14+The subjects of `q` and `r` are constrained to match any
15+pattern-matching algebra in `p`. The analysis, which is
16+conservative, understands any combination of `:fits`
17+(`?=`), `:and` (`?&`), `:or` (`?|`), and `:not` (`?!`),
18+and reduces the subject appropriately when compiling.
1519
16−Here we see two common cases of `?:` in the wide form, one uses an
17−expression `++gte` that produces a boolean and the other `?=` to
18−produce one of its cases.
20+If test analysis reveals that either branch is not taken,
21+or if `p` is not a boolean, compilation fails. However,
22+an untaken branch can be indicated with the `:lost` twig.
23+
24+## Syntax
25+
26+Regular: *3-fixed*.
27+
28+## Discussion
29+
30+Short-circuiting in boolean tests works as you'd expect
31+and includes the expected inference. For instance,
32+if you write `:(and a b)`, `b` is only executed if `a` is
33+positive, and compiled with that assumption.
34+
35+Note also that all other branching twigs reduce to `:if`.
36+
37+## Examples
38+
39+```
40+~zod:dojo> ?:((gth 1 2) 3 4)
41+4
42+```
docs/programming/advanced/catalog/wut-test/dot-lest.md+32−17
@@ -1,24 +1,39 @@
1+---
2+sort: 2
3+---
4+
15# `:lest`, `?.`, "wutdot" `{$lest p/twig q/twig r/twig}`
26
3−Inverted if-then-else.
7+Branch on a boolean test, inverted.
8+
9+## Expands to
10+
11+```
12+:if p
13+ r
14+q
15+```
16+
17+## Syntax
418
5−Unless `p` is true, evaluate `r`. Used to keep the heavier of `q` and `r` as the bottom expression, which makes for more readable code (see the section on backstep in the syntax section).
19+Regular: *3-fixed*.
620
7−Regular form: *3-fixed*
21+## Discussion
822
9−Examples:
23+As usual with inverted forms, use `:lest` when the positive
24+twig of an `:if` is much heavier than the negative twig.
1025
11− ~zod:dojo> ?.((gth 1 2) 1 2)
12− 1
13− ~zod:dojo> ?.(?=(%a 'a') %not-a %yup)
14− %yup
15− > ?. %.y
16− 'this false case is less heavy than the true case'
17− ?: =(2 3)
18− 'two not equal to 3'
19− 'but see how \'r is much heavier than \'q?'
20− 'but see how \'r is much heavier than \'q?'
26+## Examples
2127
22−Here we see two common cases of `?.` in the wide form, one uses an
23−expression `gth` that produces a boolean and the other `?=` to
24−produce one of its cases.
28+```
29+~zod:dojo> ?.((gth 1 2) 3 4)
30+3
31+~zod:dojo> ?.(?=(%a 'a') %not-a %yup)
32+%yup
33+~zod:dojo> ?. %.y
34+ 'this false case is less heavy than the true case'
35+ ?: =(2 3)
36+ 'two not equal to 3'
37+ 'but see how \'r is much heavier than \'q?'
38+'but see how \'r is much heavier than \'q?'
39+```
docs/programming/advanced/catalog/wut-test/gal-deny.md+22−10
@@ -1,15 +1,27 @@
1−# `:deny`, `?<`, "wutgal" `{$deny p/twig q/twig}`
2−====
1+---
2+sort: 10
3+---
34
4−Assert `p` is false.
5+# `:deny, ?<, "wutgal", {$deny p/seed q/seed}`
56
6−Asserts that `p` is false before evaluating `q`. Crashes if `p` evaluates to false.
7+Negative assertion.
78
8−Regular form: *2-fixed*
9+## Expands to
910
10−Examples:
11+```
12+:if p
13+ :zpzp
14+q
15+```
16+
17+## Syntax
18+
19+Regular: *2-fixed*.
20+
21+## Examples
22+
23+```
24+~zod:dojo> ?<(=(3 4) %foo)
25+%foo
26+```
1127
12− ~zod:dojo> ?<(=(0x1 0) %foo)
13− %foo
14− ~zod:dojo> ?<(=(0x1 1) %foo)
15− ! exit
docs/programming/advanced/catalog/wut-test/gar-sure.md+21−9
@@ -1,14 +1,26 @@
1−# `:sure`, `?>`, "wutgar" `{$sure p/twig q/twig}`
1+---
2+sort: 11
3+---
24
3−Assert `p` is true.
5+# `:sure, ?<, "wutgar", {$sure p/seed q/seed}`
46
5−Asserts that `p` is true before evaluating `q`, crashing if `p` evaluates to false.
7+Positive assertion.
68
7−Regular form: *2-fixed*
9+## Expands to
810
9−Examples:
11+```
12+:lest p
13+ :zpzp
14+q
15+```
1016
11− ~zod:dojo> ?>(=(0x1 1) %foo)
12− %foo
13− ~zod:dojo> ?>(=(0x1 0) %foo)
14− ! exit
17+## Syntax
18+
19+Regular: *2-fixed*.
20+
21+## Examples
22+
23+```
24+~zod:dojo> ?>(=(3 3) %foo)
25+%foo
26+```
docs/programming/advanced/catalog/wut-test/hep-case.md+49−52
@@ -1,52 +1,49 @@
1−# `:case`, `?-`, "wuthep" `{$case p/wing q/(list (pair twig twig))}`
2−
3−Switch.
4−
5−Switches on the value of `p`. `q` is a list of key value pairs, the heads of
6−which `p` attempts to match with. Different from the traditional switch
7−statement in that it switches on a type instead of a value. XX take a close
8−look at this description The most common type used to switch on is the cube,
9−which begins with `%` followed by text.
10−
11−Regular form: *1-fixed, followed by jogging*
12−
13−Examples:
14−
15− ~zod:dojo>
16− =cor |= typ/$?(%a %b)
17− ?- typ
18− %a 1
19− %b 2
20− ==
21− new var %cor
22− ~zod:dojo>
23− (cor %a)
24− 1
25− ~zod:dojo>
26− (cor %b)
27− 2
28−
29−Here is a simple example of `?-` that thows its input must have a well
30−defined type for which all of the cases are covered. We create a core,
31−`cor`, that takes an input `typ` which must be either `%a` or `%b` with
32−`$%`. Calling `cor` with valid arguments selects one of our cases.
33−
34− ~zod:dojo>
35− ?- 'a'
36− %a 0
37− %b 1
38− ==
39− ! /~zod/try/~2014.11.2..16.56.40..fca2:<[1 1].[4 7]>
40− ! -lost.@t
41− ! mint-lost
42− ~zod:dojo>
43− ?- (?(%a %b) 0)
44− %a 'a'
45− %b 'b'
46− ==
47− 'b'
48−
49−Here we can see a common failure case with `?-`. In the first example
50−all of our possible input cases are not covered when we pass in a `@t`,
51−so we fail with `mint-vain`, a compilation error. When we construct a well
52−typed input and cover all of the possible cases, we get the desired result.
1+---
2+sort: 12
3+---
4+
5+# `:case, ?-, "wuthep", {$case p/wing q/(list (pair moss seed))}`
6+
7+Switch against a union, with no default.
8+
9+## Expands to
10+
11+```
12+:ifno q
13+ :lost
14+:if :fits(p.i.q p)
15+ q.i.q
16+:moar(q t.q)
17+```
18+
19+## Syntax
20+
21+Regular: *1-fixed*, then *jogging*.
22+
23+## Discussion
24+
25+The compiler makes sure that your code neither misses a case of
26+the union, nor includes a double case that isn't there. This is
27+not special handling for `:case`, just a consequence of the
28+semantics of `:if`, which `:case` reduces to.
29+
30+A missing case will throw the `mint-lost` error. An extra case
31+will throw `mint-vain`. (Ecclesiastes did nothing wrong.)
32+
33+## Examples
34+
35+```
36+~zod:dojo> =cor |= vat/?($a $b)
37+ ?- vat
38+ $a 20
39+ $b 42
40+ ==
41+~zod:dojo> (cor %a)
42+20
43+~zod:dojo> (cor %b)
44+42
45+~zod:dojo> (cor %c)
46+! nest-fail
47+```
48+
49+
docs/programming/advanced/catalog/wut-test/ket-ifcl.md+30−34
@@ -1,39 +1,35 @@
1−# `:ifcl`, `?^`, "wutket" `{$ifcl p/wing q/twig r/twig}`
2−====
1+---
2+sort: 5
3+---
34
4−If `p` is cell-then-else.
5+# `:ifcl, ?^, "wutket", {$ifcl p/wing q/twig r/twig}`
56
6−If `p` is a cell, then produce `q`. Else, produce `r`.
7+Branch on whether a wing of the subject is null.
78
8−Regular form: *3-fixed*
9+## Expands to
10+
11+```
12+:if :fits(^ p)
13+ q
14+r
15+```
16+
17+## Syntax
918
10−Examples:
11−
12− ~zod:dojo> =(*@tas "")
13− %.y
14− ~zod:dojo> ?^ ""
15− %full
16− %empty
17− %empty
18− ~zod:dojo> ?^ "asd"
19− %full
20− %empty
21− %full
22−
23−Here we show that `*@tas`, the bunt of `@tas` is equivalent to the empty
24−`++tape` `""`, then use it in two `?^` cases.
25−
26− ~zod:dojo> *(unit)
27− ~
28− ~zod:dojo> ?^ `(unit)`~
29− %full
30− %empty
31− %empty
32− ~zod:dojo> ?^ `(unit)`[~ u=20]
33− %full
34− %empty
35− %full
36−
37−Similar to the above case, we show the bunt of a `++unit`, which is
38−`~`, and test against it.
19+Regular: *3-fixed*.
20+
21+## Discussion
22+
23+Regular form: *3-fixed*
3924
25+## Examples
26+
27+```
28+~zod:dojo> ?^(0 1 2)
29+! mint-vain
30+! exit
31+~zod:dojo> ?^(`*`0 1 2)
32+2
33+~zod:dojo> ?^(`*`[1 2] 3 4)
34+3
35+```
docs/programming/advanced/catalog/wut-test/lus-deft.md+41−59
@@ -1,59 +1,41 @@
1−# `:defl`, `?+`, "wutlus" `{$deft p/wing q/twig r/(list (pair twig twig))}`
2−
3−Switch with default value.
4−
5−Identical to `?-` except for that it takes a default case `q` if none of the
6−cases in `r` match the type of `p`. More specifically, the labels in `q` must
7−match the span of `p`. As with `?-`, the most common type used to switch on is the cube, which begins with `%` followed by text.
8−
9−Examples:
10−
11− ?- p
12− p.i.r q.i.r
13− p.i.t.r q.i.t.r
14− p.i.t.t.r q.i.t.t.r
15− * q
16− ==
17− ~zod:dojo>
18− =cor |= typ/@ta
19− ?+ typ 0
20− %a 1
21− %b 2
22− ==
23− new var %cor
24− ~zod:dojo>
25− (cor 'a')
26− 1
27− ~zod:dojo>
28− (cor 'c')
29− 0
30−
31−Here is a simple example of `?+` showing that although the cases must
32−match the span of its input, all possible cases don't need to be covered
33−since `?+` has a default case. We create a core, `cor` that takes an
34−input `typ`, a `@ta`. Calling `cor` selects one of our cases when it is
35−covered, or the default.
36−
37− ~zod:dojo>
38− ?+ 'a' 0
39− %a 1
40− ==
41− 1
42− ~zod:dojo>
43− ?+ [0 'a'] 0
44− %a 1
45− ==
46− ! poke-mack-fail
47− ! /~zod/try/~2014.11.2..16.45.31..7b2a:<[1 1].[3 7]>
48− ! mint-vain
49− ! ford: call ~hidper-sommur
50− ! poking %poke-txt
51− ! error in app %shell on ~zod at instance /shell/terminal
52− ~zod:dojo>
53− ?+ [0 1] 0
54− [0 %a] 1
55− ==
56− 0
57−
58−This example shows how `?+` can fail. Our input span must match the span
59−of our cases.
1+---
2+sort: 13
3+---
4+
5+# `:deft, ?-, "wutlus", {$case p/wing q/seed r/(list (pair moss seed))}`
6+
7+Switch against a union, with a default.
8+
9+## Expands to
10+
11+```
12+:ifno r
13+ q
14+:if :fits(p.i.r p)
15+ q.i.r
16+:moar(r t.r)
17+```
18+
19+## Syntax
20+
21+Regular: *2-fixed*, then *jogging*.
22+
23+## Discussion
24+
25+An extra case will throw `mint-vain`. A lost case defaults.
26+
27+## Examples
28+
29+```
30+~zod:dojo> =cor |= vat/?($a $b)
31+ ?+ vat 240
32+ $a 20
33+ $b 42
34+ ==
35+~zod:dojo> (cor %a)
36+20
37+~zod:dojo> (cor %b)
38+42
39+~zod:dojo> (cor %c)
40+240
41+```
docs/programming/advanced/catalog/wut-test/pam-and.md+23−17
@@ -1,24 +1,30 @@
1−# `:and`, `?&`, "wutpam" `{$and p/(list twig)}`
1+---
2+sort: 8
3+---
24
3−Logical 'and'.
5+# `:and, ?&, "wutpam", {$and p/(list seed)}`
46
5−Computes the logical 'and' operation on a list of boolean expressions `p`.
7+Logical and.
68
7−Regular form: *running*
9+## Expands to
810
9−Irregular form:
11+```
12+:ifno p
13+ &
14+:lest i.p
15+ |
16+:moar(p t.p)
17+```
1018
11−`&(a b c) ?&(a b c)`
19+## Syntax
1220
13−Examples:
21+Regular: *running*.
1422
15− ~zod:dojo> ?&(& &)
16− %.y
17− ~zod:dojo> &(& &)
18− %.y
19− ~zod:dojo> &(& |)
20− %.n
21− ~zod:dojo> &((gth 2 1) |)
22− %.n
23− ~zod:dojo> &((gth 2 1) &)
24− %.y
23+Irregular: `&(foo bar baz)` is `?&(foo bar baz)`.
24+
25+## Examples
26+
27+```
28+~zod:dojo> &(=(6 6) =(42 42))
29+%.y
30+```
docs/programming/advanced/catalog/wut-test/pat-ifat.md+26−18
@@ -1,23 +1,31 @@
1−# `:ifat`, `?&`, "wutpam" `{$ifat p/wing q/twig r/twig}`
1+---
2+sort: 4
3+---
24
3−If atom-then-else.
5+# `:ifat, ?@, "wutpat", {$ifat p/wing q/seed r/seed}`
46
5−If-then-else statement that tests whether `p` is an atom, producing `q` if true and `r` if false.
7+Branch on whether a wing of the subject is an atom.
68
7−Examples:
9+## Expands to
810
9− ~zod:dojo> ?@(~ 1 2)
10− ! mint-vain
11− ! exit
12− ~zod:dojo> ?@(%ha 1 2)
13− 1
14− ~zod:dojo> ?@("" 1 2)
15− 1
16− ~zod:dojo> ?@("a" 1 2)
17− 2
18− ~zod:dojo> ?@([1 1] 1 2)
19− ! mint-vain
20− ! exit
21− ~zod:dojo> ?@(`*`[1 1] 1 2)
22− 2
11+```
12+:if :fits($~ p)
13+ q
14+r
15+```
2316
17+## Syntax
18+
19+Regular: *3-fixed*.
20+
21+## Examples
22+
23+```
24+~zod:dojo> ?@(0 1 2)
25+! mint-vain
26+! exit
27+~zod:dojo> ?@(`*`0 1 2)
28+1
29+~zod:dojo> ?@(`*`[1 2] 3 4)
30+4
31+```
docs/programming/advanced/catalog/wut-test/sig-ifno.md+26−15
@@ -1,21 +1,32 @@
1−# `ifno`, `?~`, "wutsig" `{$ifno p/wing q/twig r/twig}`
2−====
1+---
2+sort: 3
3+---
34
4−If-null-then-else.
5+# `ifno`, `?~`, "wutsig" `{$ifno p/wing q/seed r/seed}`
56
6−If-then-else statement that tests whether `p` is null, producing `q` if true
7−and `r` if false.
7+Branch on whether a wing of the subject is null.
8+
9+## Expands to
810
9−Regular form: *3-fixed*
11+```
12+:if :fits($~ p)
13+ q
14+r
15+```
1016
11−Examples:
17+## Syntax
1218
13− ~zod:dojo> ?~('a' 1 2)
14− 2
15− ~zod:dojo> ?~('' 1 2)
16− 1
17− ~zod:dojo> ?~(~zod 1 2)
18− 1
19− ~zod:dojo> ?~((sub 20 20) 1 2)
20− 1
19+Regular: *3-fixed*.
2120
21+## Discussion
22+
23+It's bad style to use `:ifno` to test for any zero atom. Use it
24+only for a true null, `~`.
25+
26+## Examples
27+
28+```
29+~zod:dojo> =foo ""
30+~zod:dojo> ?~(foo 1 2)
31+11
32+```
docs/programming/advanced/catalog/wut-test/tis-fits.md+35−14
@@ -1,19 +1,40 @@
1−# `:ifits`, `?=`, "wuttis" `{$fits p/twig q/wing}
2−====
1+---
2+sort: 6
3+---
34
4−Is `q` within type `p`.
5+# `:fits, ?=, "wuttis", {$fits p/moss q/wing}
56
6−Tests whether `q` is of mold `p`.
7+Test whether the noun at wing `q` fits pattern `p`.
78
8−Regular form: *2-fixed*
9+## Produces
910
10−Examples:
11+`&` (yes) if the noun at `q` is in the icon of `p`;
12+`|` (no) otherwise.
1113
12− ~zod:dojo> ?=(@ 'a')
13− %.y
14− ~zod:dojo> ?=(^ 'a')
15− %.n
16− ~zod:dojo> ?=(%b 'a')
17− %.n
18− ~zod:dojo> ?=(%a 'a')
19− %.y
14+## Syntax
15+
16+Regular: *2-fixed*.
17+
18+## Discussion
19+
20+`:fits` is not as powerful as it might seem. For instance, it
21+can't generate a loop -- you cannot (and should not) use it to
22+test whether a `*` is a `(list @)`. Nor can it validate atomic
23+auras.
24+
25+Patterns should be as weak as possible. Unpack one layer of
26+union at a time. Don't confirm things the type system knows.
27+
28+For example, when matching a book containing a page `{$foo p/@
29+q/{@ @}}`, the proper pattern is `{$foo *}`. You have one
30+question, which is whether the head of the noun is `%foo`.
31+
32+A common error is `find.$`, meainng `p` is not a mold.
33+
34+## Examples
35+
36+```
37+~zod:dojo> =bar [%foo %bar %baz]
38+~zod:dojo> ?=({$foo *} bar)
39+%.y
40+```
docs/programming/advanced/catalog/wut-test/zap-not.md+27−16
@@ -1,21 +1,32 @@
1−# `:not`, `?!`, "wutzap" `{$not p/twig}`
1+---
2+sort: 7
3+---
4+
5+# `:not, ?!, "wutzap", {$not p/seed}`
26
37Logical not.
48
9+## Expands to
10+
11+```
12+:same(%.n p)
13+```
14+
515Produces the logical "not" of `p`.
616
7−Regular form: *1-fixed*
8−
9−Examples:
10−
11− ~zod:dojo> !&
12− %.n
13− ~zod:dojo> !|
14− %.y
15− ~zod:dojo> (gth 5 6)
16− %.n
17− ~zod:dojo> !(gth 5 6)
18− %.y
19− ~zod:dojo> !1
20− ! type-fail
21− ! exit
17+## Syntax
18+
19+Regular: *1-fixed*.
20+
21+Irregular: `!(foo)` is `?!(foo)`.
22+
23+## Examples
24+
25+```
26+~zod:dojo> !&
27+%.n
28+~zod:dojo> !|
29+%.y
30+~zod:dojo> !(gth 5 6)
31+%.y
32+```
docs/programming/twig/mold.md+1−1
@@ -11,7 +11,7 @@ molds are often called "structures.")
1111## Overview
1212
1313While Hoon can't check this property statically, a proper mold
14−is a *rectifier*: an idempotent function across all nouns. If
14+is a *normalizer*: an idempotent function across all nouns. If
1515the sample of a gate has span `%noun`, and its body obeys the
1616constraint that for any x, `=((mold x) (mold (mold x)))`, it's a
1717rectifier and can be used as a mold.