2title = "Irregular forms"
5aliases = ["docs/reference/hoon-expressions/irregular/"]
8## Quick Lookup of Irregular Forms
10| Form | Regular Form |
11| ---- | ------------ |
12| `_foo` | [`$_`](https://urbit.org/docs/hoon/reference/rune/buc#_-buccab), normalizes to an example |
13| `foo=bar` | [`$=`](https://urbit.org/docs/hoon/reference/rune/buc#_-buctis), wraps a face around a value |
14| `?(%foo %bar %baz)` | [`$?`](https://urbit.org/docs/hoon/reference/rune/buc#_-bucwut), forms a type union |
15| `(fun a b c)` | [`%:`](https://urbit.org/docs/hoon/reference/rune/cen#_-cencol), calls a gate with n arguments |
16| `~(arm core arg)` | [`%~`](https://urbit.org/docs/hoon/reference/rune/cen#_-censig), pulls an arm in a door |
17| `foo(x 1, y 2, z 3)` | [`%=`](https://urbit.org/docs/hoon/reference/rune/cen#_-centis), resolve a wing with changes |
18| `[a b c]` | [`:*`](https://urbit.org/docs/hoon/reference/rune/col#_-coltar) or [`$:`](https://urbit.org/docs/hoon/reference/rune/buc#_-buccol), constructs _n_-tuple in normal mode or its structure in structure mode |
19| `~[a b c]` | [`:~`](https://urbit.org/docs/hoon/reference/rune/col#_-colsig), constructs null-terminated list |
20| `+(42)` | [`.+`](https://urbit.org/docs/hoon/reference/rune/dot#_-dotlus), increments with Nock 4 |
21| `=(a b)` | [`.=`](https://urbit.org/docs/hoon/reference/rune/dot#_-dottis), tests for equality wiht Nock 5 |
22| ``foo`bar` | [`^-`](https://urbit.org/docs/hoon/reference/rune/ket#_-kethep), typecasts by explicit type label |
23| `foo=bar` | [`^=`](https://urbit.org/docs/hoon/reference/rune/ket#_-kettis), binds name to value |
24| `*foo` | [`^*`](https://urbit.org/docs/hoon/reference/rune/ket#_-kettar), bunts (produces default mold value) |
25| `,foo` | [`^:`](https://urbit.org/docs/hoon/reference/rune/ket#_-ketcol), produces “factory” gate for type |
26| `:(fun a b c d)` | [`;:`](https://urbit.org/docs/hoon/reference/rune/mic#_-miccol), calls binary function as _n_-ary function |
27| `foo:bar` | [`=<`](https://urbit.org/docs/hoon/reference/rune/tis#_-tisgal), composes two expressions, inverted |
28| `|(foo bar baz)` | [`?|`](https://urbit.org/docs/hoon/reference/rune/wut#_-wutbar), logical OR (loobean) |
29| `&(foo bar baz)` | [`?&`](https://urbit.org/docs/hoon/reference/rune/wut#_-wutpam), logical AND (loobean) |
30| `!foo` | [`?!`](https://urbit.org/docs/hoon/reference/rune/wut#_-wutzap), logical NOT (loobean) |
34Headings contain runes, phonetics and tokens. Description contains a link to the
35docs and a short description of the rune. Both regular and irregular forms are given.
37Want 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.
41Anything Nock can do, Hoon can do also.
45[docs](/docs/hoon/reference/rune/dot#dotlus) \\+
47`[%dtls p=atom]`: increment an atom with Nock 4.
55[docs](/docs/hoon/reference/rune/dot#dottis) \\=
57`[%dtts p=hoon q=hoon]`: test for equality with Nock 5.
65Miscellaneous useful macros.
69[docs](/docs/hoon/reference/rune/mic#miccol) \\:
71`[%mccl p=hoon q=(list hoon)]`: call a binary function as an n-ary function.
83[docs](/docs/hoon/reference/rune/col#colhep) \\[\\]\\^\\+\\\`\\~
85`[%clhp p=hoon q=hoon]`: construct a cell (2-tuple).
104Flow hoons change the subject. All non-flow hoons (except cores) pass the subject down unchanged.
108[docs](/docs/hoon/reference/rune/tis#tisgal) \\:
110`[%tsgl p=hoon q=hoon]`: compose two hoons, inverted.
118[docs](/docs/hoon/reference/rune/bar) \\$
120Core hoons are flow hoon.
122Technically not irregular syntax, but worth mentioning.
129The 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: `$()`.
133The invocation family of runes.
137[docs](/docs/hoon/reference/rune/cen#centis) \\(\\)
139`[%cnts p=wing q=(list (pair wing hoon))]`: take a wing with changes.
147[docs](/docs/hoon/reference/rune/cen#censig) \\~
149`[%cnsg p=wing q=hoon r=hoon]`: call with multi-armed door.
157[docs](/docs/hoon/reference/rune/cen#cenhep) \\(\\)
159`[%cnhp p=hoon q=hoon]`: call a gate (function).
165Note: `(p)` becomes `$:p` (`=<($ p)`), which behaves as you would expect (func call w/o args).
169A mold is a gate (function) that helps us build simple and rigorous data structures.
173[docs](/docs/hoon/reference/rune/buc#bucwut) \\?
175`[%bcwt p=(list model)]`: mold which normalizes a general union.
183[docs](/docs/hoon/reference/rune/buc#buccab) \\\_
185`[%bccb p=value]`: mold which normalizes to an example.
193Hoon has the usual branches and logical tests.
197[docs](/docs/hoon/reference/rune/wut#wutzap) \\!
199`[%wtzp p=hoon]`: logical not.
207[docs](/docs/hoon/reference/rune/wut#wutpam) \\&
209`[%wtpm p=(list hoon)]`: logical and.
217[docs](/docs/hoon/reference/rune/wut#wutbar) \\|
219`[%wtbr p=(list hoon)]`: logical or.
227Lets us adjust types without violating type constraints.
231[docs](/docs/hoon/reference/rune/ket#ketcol) \\,
233`[%ktcl p=spec]`: mold gate for type `p`.
241[docs](/docs/hoon/reference/rune/ket#kethep) \\\`
243`[%kthp p=model q=value]`: typecast by mold.
251[docs](/docs/hoon/reference/rune/ket#kettar) \\\*
253`[%kttr p=spec]`: produce bunt value of mold.
261[docs](/docs/hoon/reference/rune/ket#kettis) \\=
263`[%ktts p=toga q=value]`: name a value.
286- `%a` constant `a`, where `a` can be an ((ir)regularly defined) atom or a symbol.
288See [%sand](/docs/hoon/reference/rune/constants#warm) for other irregular definitions of atoms.
292- `&n` nth element of a list.
293- `|n` tail of list after nth element (i.e. n is the head).
297[docs](/docs/hoon/reference/limbs/limb) \\+\\.\\^
299`[%limb p=(each @ud [p=@ud q=@tas])]`: attribute of subject.
302- `.` is the whole subject (slot 1)
303- `^a` is the `a` "of a higher scope", i.e. "resolve variable a, ignoring the first one found".
304- `^^p` even higher, etc.
305- 'Lark' syntax for slots / tree addressing:
321[docs](content/docs/hoon/reference/limbs/wing)
322`[%wing p=(list limb)]`; a limb search path.
323`a.b` finds limb `a` within limb `b` ("var" `a` within "var" `b`).
327- `<a b c>` prints a [tape](/docs/hoon/reference/stdlib/2q/#-tape).
328- `>a b c<` prints a [tank](/docs/hoon/reference/stdlib/2q/#-tank).
332In 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.
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list