on bab7ff8 help sign in
urbit.org/hoon/reference/irregular.md
257 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+b ==> [%a b]
64 `a ==> [~ a]
65 ~[a b] ==> [a b ~]
66 [a b]~ ==> [[a b] ~]
67```
69## = tis (flow)
71Flow hoons change the subject. All non-flow hoons (except cores) pass the subject down unchanged.
73### =< tisgal
75[docs](@/docs/hoon/reference/rune/tis.md#tisgal) \\:
76`[%tsgl p=hoon q=hoon]`: compose two hoons, inverted.
78R: `=<(p q)`
79I: `p:q`
81## | bar (core)
83[docs](@/docs/hoon/reference/rune/bar.md) \\$
84Core hoons are flow hoon.
86Technically not irregular syntax, but worth mentioning.
88- `|= bartis`
89- `|. bardot`
90- `|- barhep`
91- `|* bartar`
93The 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: `$()`.
95## % cen (call)
97The invocation family of runes.
99### %= centis
101[docs](@/docs/hoon/reference/rune/cen.md#centis) \\(\\)
102`[%cnts p=wing q=(list (pair wing hoon))]`: take a wing with changes.
104R: `%=(p a 1)`
105I: `p(a 1)`
107### %~ censig
109[docs](@/docs/hoon/reference/rune/cen.md#censig) \\~
110`[%cnsg p=wing q=hoon r=hoon]`: call with multi-armed door.
112R: `%~(p q r)`
113I: `~(p q r)`
115### %- cenhep
117[docs](@/docs/hoon/reference/rune/cen.md#cenhep) \\(\\)
118`[%cnhp p=hoon q=hoon]`: call a gate (function).
120R: `%-(p q)`
121I: `(p q)`
123Note: `(p)` becomes `$:p` (`=<($ p)`), which behaves as you would expect (func call w/o args).
125## $ buc (mold)
127A mold is a gate (function) that helps us build simple and rigorous data structures.
129### $? bucwut
131[docs](@/docs/hoon/reference/rune/buc.md#bucwut) \\?
132`[%bcwt p=(list model)]`: mold which normalizes a general union.
134R: `$?(p)`
135I: `?(p)`
137### $_ buccab
139[docs](@/docs/hoon/reference/rune/buc.md#buccab) \\_
140`[%bccb p=value]`: mold which normalizes to an example.
142R: `$_(p)`
143I: `_p`
145## ? wut (test)
147Hoon has the usual branches and logical tests.
149### ?! wutzap
151[docs](@/docs/hoon/reference/rune/wut.md#wutzap) \\!
152`[%wtzp p=hoon]`: logical not.
154R: `?!(p)`
155I: `!(p)`
157### ?& wutpam
159[docs](@/docs/hoon/reference/rune/wut.md#wutpam) \\&
160`[%wtpm p=(list hoon)]`: logical and.
162R: `?&(p)`
163I: `&(p)`
165### ?| wutbar
167[docs](@/docs/hoon/reference/rune/wut.md#wutbar) \\|
168`[%wtbr p=(list hoon)]`: logical or.
170R: `?|(p)`
171I: `|(p)`
173## ^ ket (cast)
175Lets us adjust types without violating type constraints.
177### ^- kethep
179[docs](@/docs/hoon/reference/rune/ket.md#kethep) \\\`
180`[%kthp p=model q=value]`: typecast by mold.
182R: `^-(p q)`
183I: `` `p`q ``
185### ^= kettis
187[docs](@/docs/hoon/reference/rune/ket.md#kettis) \\=
188`[%ktts p=toga q=value]`: name a value.
190R: `^=(p q)`
191I: `p=q`
193## Miscellaneous
195### Trivial molds
197- `*` noun.
198- `@` atom.
199- `^` cell.
200- `?` loobean.
201- `~` null.
204### Values
206\\~\\-\\.\\&\\|
208- `~` null.
209- `&` loobean true.
210- `|` loobean false.
211- `%a` constant `a`, where `a` can be an ((ir)regularly defined) atom or a symbol.
213See [%sand](@/docs/hoon/reference/rune/constants.md#warm) for other irregular definitions of atoms.
215### List addressing
217- `&n` nth element of a list.
218- `|n` tail of list after nth element (i.e. n is the head).
220### Limbs
222[docs](@/docs/hoon/reference/limbs/limb.md) \\+\\.\\^
223`[%limb p=(each @ud [p=@ud q=@tas])]`: attribute of subject.
225- `+15` is slot 15
226- `.` is the whole subject (slot 1)
227- `^a` is the `a` "of a higher scope", i.e. "resolve variable a, ignoring the first one found".
228- `^^p` even higher, etc.
229- 'Lark' syntax for slots / tree addressing:
230```
231+1
232+2 -
233+3 +
234+4 -<
235+5 ->
236+6 +<
237+7 +>
238+8 -<-
239...
240```
243### Wings
245[docs](content/docs/hoon/reference/limbs/wing.md)
246`[%wing p=(list limb)]`; a limb search path.
247`a.b` finds limb `a` within limb `b` ("var" `a` within "var" `b`).
249### Printing stuff
251- `<a b c>` prints a [tape](../library/2q/#-tape).
252- `>a b c<` prints a [tank](../library/2q/#-tank).
254## Commentary
256In 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.