@@ -0,0 +1,279 @@
1+---
2+navhome: /docs/
3+sort: 21
4+title: Irregular forms
5+comments: true
6+---
7+
8+## Irregular forms, a compilation
9+##### `~palfun-foslup`
10+
11+<br />
12+
13+*Original `fora` post* [*here*](http://urbit.org/fora/posts/~2016.12.29..19.37.08..89d5~/).
14+
15+##### Reading guide
16+Headings contain runes, phonetics and tokens. Description contains a link to the docs and a short description of the rune. Both regular (R) and irregular (I) forms are given.
17+
18+Want to `ctrl-f` to find out the meaning of something weird you saw? Search for `\symbol`. ie `\?` or `\=`. It'll show you to the irregular forms that uses that symbol.
19+
20+## . dot (nock)
21+
22+Anything Nock can do, Hoon can do also.
23+
24+### .+ dotlus :bump
25+
26+[docs](https://urbit.org/docs/hoon/twig/dot-nock/lus-bump/) \\+
27+`{$bump p/atom}`: increment an atom with Nock 4.
28+
29+R: `.+(p)`
30+I: `+(p)`
31+
32+### .= dottis :same
33+
34+[docs](https://urbit.org/docs/hoon/twig/dot-nock/tis-same/) \\=
35+`{$same p/seed q/seed}`: test for equality with Nock 5.
36+
37+R: `.=(p q)`
38+I: `=(p q)`
39+
40+## ; sem (make)
41+
42+Miscellaneous useful macros.
43+
44+### ;: semcol :wad
45+
46+[docs](https://urbit.org/docs/hoon/twig/sem-make/col-wad/) \\:
47+`{$wad p/seed q/(list seed)}`: call a binary function as an n-ary function.
48+
49+R: `;:(p q)`
50+I: `:(p q)`
51+
52+## : col (cells)
53+
54+The cell twigs.
55+
56+### :- colhep :cons
57+
58+[docs](https://urbit.org/docs/hoon/twig/col-cell/hep-cons/) \\[\\]\\^\\+\\\`\\~
59+`{$cons p/seed q/seed}`: construct a cell (2-tuple).
60+
61+R: `:-(p q)`
62+I:
63+
64+```
65+ [a b] ==> :-(a b)
66+[a b c] ==> [a [b c]]
67+ a^b^c ==> [a b c]
68+ a+b ==> [%a b]
69+ `a ==> [~ a]
70+ ~[a b] ==> [a b ~]
71+ [a b]~ ==> [[a b] ~]
72+```
73+
74+## = tis (flow)
75+
76+Flow twigs change the subject. All non-flow twigs (except cores) pass the subject down unchanged.
77+
78+### =< tisgal :rap
79+
80+[docs](https://urbit.org/docs/hoon/twig/tis-flow/gal-rap/) \\:
81+`{$rap p/seed q/seed}`: compose two twigs, inverted.
82+
83+R: `=<(p q)`
84+I: `p:q`
85+
86+## | bar (core)
87+
88+[docs](https://urbit.org/docs/hoon/twig/bar-core/) \\$
89+Core twigs are flow twigs.
90+
91+Technically not irregular syntax, but worth mentioning.
92+
93+* `|= bartis :gate`
94+* `|. bardot :trap`
95+* `|- barhep :loop`
96+* `|* bartar :gill`
97+
98+The above runes produce a core with a single arm, named `$` (or `:moar`). We can recompute this arm with changes, useful for recursion among other things. Commonly used with the irregular syntax for `%=`, `:make`, like so: `$()`.
99+
100+## % cen (call)
101+
102+The invocation family of twigs.
103+
104+### %= centis :make
105+
106+[docs](https://urbit.org/docs/hoon/twig/cen-call/tis-make/) \\(\\)
107+`{$make p/wing q/(list (pair wing seed))}`: take a wing with changes.
108+
109+R: `%=(p a 1)`
110+I: `p(a 1)`
111+
112+### %~ censig :open
113+
114+[docs](https://urbit.org/docs/hoon/twig/cen-call/sig-open/) \\~
115+`{$cnsg p/wing q/seed r/seed}`: call with multi-armed door.
116+
117+R: `%~(p q r)`
118+I: `~(p q r)`
119+
120+### %- cenhep :call
121+
122+[docs](https://urbit.org/~~/docs/hoon/twig/cen-call/hep-call/) \\(\\)
123+`{$call p/seed q/seed}`: call a gate (function).
124+
125+R: `%-(p q)`
126+I: `(p q)`
127+
128+Note: `(p)` becomes `$:p` (`=<($ p)`), which behaves as you would expect (func call w/o args).
129+
130+## $ buc (mold)
131+
132+A mold is a gate (function) that helps us build simple and rigorous data structures.
133+
134+### $: buccol :bank
135+
136+[docs](https://urbit.org/docs/hoon/twig/buc-mold/col-bank/) \\{\\}
137+`{$bank p/(list moss)}`: form a mold which recognizes a tuple.
138+
139+R: `$:(p q)`
140+I: `{p q}`
141+
142+### $= buctis :coat
143+
144+[docs](https://urbit.org/docs/hoon/twig/buc-mold/tis-coat/) \\/
145+`{$coat p/@tas q/moss}`: mold which wraps a face around another mold.
146+
147+R: `$=(p q)`
148+I: `p/q`
149+
150+### $? bucwut :pick
151+
152+[docs](https://urbit.org/docs/hoon/twig/buc-mold/wut-pick/) \\?
153+`{$pick p/(list moss)}`: mold which normalizes a general union.
154+
155+R: `$?(p)`
156+I: `?(p)`
157+
158+### $_ buccab :shoe
159+
160+[docs](https://urbit.org/docs/hoon/twig/buc-mold/cab-shoe/) \\_
161+`{$shoe p/seed}`: mold which normalizes to an example.
162+
163+R: `$_(p)`
164+I: `_p`
165+
166+## ? wut (test)
167+
168+Hoon has the usual branches and logical tests.
169+
170+### ?! wutzap :not
171+
172+[docs](https://urbit.org/docs/hoon/twig/wut-test/zap-not/) \\!
173+`{$not p/seed}`: logical not.
174+
175+R: `?!(p)`
176+I: `!(p)`
177+
178+### ?& wutpam :and
179+
180+[docs](https://urbit.org/docs/hoon/twig/wut-test/pam-and/) \\&
181+`{$and p/(list seed)}`: logical and.
182+
183+R: `?&(p)`
184+I: `&(p)`
185+
186+### ?& wutbar :or
187+
188+[docs](https://urbit.org/docs/hoon/twig/wut-test/bar-or/) \\|
189+`{$or p/(list seed)}`: logical or.
190+
191+R: `?|(p)`
192+I: `|(p)`
193+
194+## ^ ket (cast)
195+
196+Lets us adjust spans without violating type constraints.
197+
198+### ^- kethep :cast
199+
200+[docs](https://urbit.org/docs/hoon/twig/ket-cast/hep-cast/) \\\`
201+`{$cast p/moss q/seed}`: typecast by mold.
202+
203+R: `^-(p q)`
204+I: ```p`q``
205+
206+### ^= kettis :name
207+
208+[docs](https://urbit.org/docs/hoon/twig/ket-cast/tis-name/) \\=
209+`{$name p/toga q/seed}`: name a value.
210+
211+R: `^=(p q)`
212+I: `p=q`
213+
214+## Miscellaneous
215+
216+### Trivial molds
217+
218+\\*\\^\\?
219+
220+* `*` noun.
221+* `^` cell.
222+* `?` loobean.
223+* `$~` null.
224+
225+### Values
226+
227+\\~\\-\\.\\&\\|
228+
229+* `~` null.
230+* `&` loobean true.
231+* `|` loobean false.
232+* `%a` constant `a`, where `a` can be an ((ir)regularly defined) atom or a symbol.
233+
234+See [:sand](https://urbit.org/docs/hoon/twig/atom/sand/) for other irregular definitions of atoms.
235+
236+### List addressing
237+* `&n` nth element of a list.
238+* `|n` tail of list after nth element (i.e. n is the head).
239+
240+### Limbs :limb
241+
242+[docs](https://urbit.org/docs/hoon/twig/limb/limb/) \\+\\.\\^
243+`{$limb p/(each @ud {p/@ud q/@tas})}`: attribute of subject.
244+
245+* `+15` is slot 15
246+* `.` is the whole subject (slot 1)
247+* `^a` is the `a` "of a higher scope", i.e. "resolve variable a, ignoring the first one found".
248+* `^^p` even higher, etc.
249+* 'Lark' syntax for slots / tree addressing:
250+```
251++1
252++2 -
253++3 +
254++4 -<
255++5 ->
256++6 +<
257++7 +>
258++8 -<-
259+...
260+```
261+
262+
263+### Wings :wing
264+
265+[docs](https://urbit.org/~~/docs/hoon/twig/limb/wing/) \\.
266+`{$wing p/(list limb)`; a limb search path.
267+
268+`a.b` finds limb `a` within limb `b` ("var" `a` within "var" `b`).
269+
270+### Printing stuff
271+
272+* `<a b c>` prints a [tape](https://urbit.org/docs/hoon/library/2q/#-tape).
273+* `>a b c<` prints a [tank](https://urbit.org/docs/hoon/library/2q/#-tank).
274+
275+## Commentary
276+
277+ In our in-house examples throughout our documentation, we use irregular forms instead of regular for the sake of verbosity. But remember with irregular forms: everything is just runes! Like magic. In general, irregular forms (usually) read better, but of course regular forms provide more information about what you're doing by showing you the full rune. Of course, it's up to you, the Hoon programmer, as to whether or not you want to use these.
278+
279+ ##### If we missed any, or if you saw something weird that's not in here, feel free to comment below!