on 979ae21 help sign in
urbit.org/hoon/reference/irregular.md
256 lines 5.6 kB history raw
1+++
2title = "Irregular forms"
3weight = 20
4template = "doc.html"
5aliases = ["docs/reference/hoon-expressions/irregular/"]
6+++
8##### Reading guide
10Headings 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.
12Want 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.
14## . dot (nock)
16Anything Nock can do, Hoon can do also.
18### .+ dotlus
20[docs](@/docs/hoon/reference/rune/dot.md#dotlus) \\+
21`[%dtls p=atom]`: increment an atom with Nock 4.
23R: `.+(p)`
24I: `+(p)`
26### .= dottis
28[docs](@/docs/hoon/reference/rune/dot.md#dottis) \\=
29`[%dtts p=hoon q=hoon]`: test for equality with Nock 5.
31R: `.=(p q)`
32I: `=(p q)`
34## ; mic (make)
36Miscellaneous useful macros.
38### ;: miccol
40[docs](@/docs/hoon/reference/rune/mic.md#miccol) \\:
41`[%mccl p=hoon q=(list hoon)]`: call a binary function as an n-ary function.
43R: `;:(p q)`
44I: `:(p q)`
46## : col (cells)
48The cell runes.
50### :- colhep
52[docs](@/docs/hoon/reference/rune/col.md#colhep) \\[\\]\\^\\+\\\`\\~
53`[%clhp p=hoon q=hoon]`: construct a cell (2-tuple).
55R: `:-(p q)`
56I:
58```
59 [a b] ==> :-(a b)
60[a b c] ==> [a [b c]]
61 a^b^c ==> [a b c]
62 a/b ==> [%a b]
63 `a ==> [~ a]
64 ~[a b] ==> [a b ~]
65 [a b]~ ==> [[a b] ~]
66```
68## = tis (flow)
70Flow hoons change the subject. All non-flow hoons (except cores) pass the subject down unchanged.
72### =< tisgal
74[docs](@/docs/hoon/reference/rune/tis.md#tisgal) \\:
75`[%tsgl p=hoon q=hoon]`: compose two hoons, inverted.
77R: `=<(p q)`
78I: `p:q`
80## | bar (core)
82[docs](@/docs/hoon/reference/rune/bar.md) \\$
83Core hoons are flow hoon.
85Technically not irregular syntax, but worth mentioning.
87- `|= bartis`
88- `|. bardot`
89- `|- barhep`
90- `|* bartar`
92The above runes produce a core with a single arm, named `$` ("buc"). We can recompute this arm with changes, useful for recursion among other things. Commonly used with the irregular syntax for `%=`, `:make`, like so: `$()`.
94## % cen (call)
96The invocation family of runes.
98### %= centis
100[docs](@/docs/hoon/reference/rune/cen.md#centis) \\(\\)
101`[%cnts p=wing q=(list (pair wing hoon))]`: take a wing with changes.
103R: `%=(p a 1)`
104I: `p(a 1)`
106### %~ censig
108[docs](@/docs/hoon/reference/rune/cen.md#censig) \\~
109`[%cnsg p=wing q=hoon r=hoon]`: call with multi-armed door.
111R: `%~(p q r)`
112I: `~(p q r)`
114### %- cenhep
116[docs](@/docs/hoon/reference/rune/cen.md#cenhep) \\(\\)
117`[%cnhp p=hoon q=hoon]`: call a gate (function).
119R: `%-(p q)`
120I: `(p q)`
122Note: `(p)` becomes `$:p` (`=<($ p)`), which behaves as you would expect (func call w/o args).
124## $ buc (mold)
126A mold is a gate (function) that helps us build simple and rigorous data structures.
128### $? bucwut
130[docs](@/docs/hoon/reference/rune/buc.md#bucwut) \\?
131`[%bcwt p=(list model)]`: mold which normalizes a general union.
133R: `$?(p)`
134I: `?(p)`
136### $_ buccab
138[docs](@/docs/hoon/reference/rune/buc.md#buccab) \\_
139`[%bccb p=value]`: mold which normalizes to an example.
141R: `$_(p)`
142I: `_p`
144## ? wut (test)
146Hoon has the usual branches and logical tests.
148### ?! wutzap
150[docs](@/docs/hoon/reference/rune/wut.md#wutzap) \\!
151`[%wtzp p=hoon]`: logical not.
153R: `?!(p)`
154I: `!(p)`
156### ?& wutpam
158[docs](@/docs/hoon/reference/rune/wut.md#wutpam) \\&
159`[%wtpm p=(list hoon)]`: logical and.
161R: `?&(p)`
162I: `&(p)`
164### ?| wutbar
166[docs](@/docs/hoon/reference/rune/wut.md#wutbar) \\|
167`[%wtbr p=(list hoon)]`: logical or.
169R: `?|(p)`
170I: `|(p)`
172## ^ ket (cast)
174Lets us adjust types without violating type constraints.
176### ^- kethep
178[docs](@/docs/hoon/reference/rune/ket.md#kethep) \\\`
179`[%kthp p=model q=value]`: typecast by mold.
181R: `^-(p q)`
182I: `` `p`q ``
184### ^= kettis
186[docs](@/docs/hoon/reference/rune/ket.md#kettis) \\=
187`[%ktts p=toga q=value]`: name a value.
189R: `^=(p q)`
190I: `p=q`
192## Miscellaneous
194### Trivial molds
196- `*` noun.
197- `@` atom.
198- `^` cell.
199- `?` loobean.
200- `~` null.
203### Values
205\\~\\-\\.\\&\\|
207- `~` null.
208- `&` loobean true.
209- `|` loobean false.
210- `%a` constant `a`, where `a` can be an ((ir)regularly defined) atom or a symbol.
212See [%sand](@/docs/hoon/reference/rune/constants.md#warm) for other irregular definitions of atoms.
214### List addressing
216- `&n` nth element of a list.
217- `|n` tail of list after nth element (i.e. n is the head).
219### Limbs
221[docs](@/docs/hoon/reference/limbs/limb.md) \\+\\.\\^
222`[%limb p=(each @ud [p=@ud q=@tas])]`: attribute of subject.
224- `+15` is slot 15
225- `.` is the whole subject (slot 1)
226- `^a` is the `a` "of a higher scope", i.e. "resolve variable a, ignoring the first one found".
227- `^^p` even higher, etc.
228- 'Lark' syntax for slots / tree addressing:
229```
230+1
231+2 -
232+3 +
233+4 -<
234+5 ->
235+6 +<
236+7 +>
237+8 -<-
238...
239```
242### Wings
244[docs](content/docs/hoon/reference/limbs/wing.md)
245`[%wing p=(list limb)]`; a limb search path.
246`a.b` finds limb `a` within limb `b` ("var" `a` within "var" `b`).
248### Printing stuff
250- `<a b c>` prints a [tape](../library/2q/#-tape).
251- `>a b c<` prints a [tank](../library/2q/#-tank).
253## Commentary
255In 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.