on c19bc7a help sign in
urbit.org/docs/reference/irregular.udon
265 lines 5.4 kB history raw
1:- :~ navhome/'/docs/'
2 sort/'7'
3 title/'Irregular forms'
4 ==
5;>
7## Irregular forms, a compilation
9##### `~palfun-foslup`
11;br;
13*Original Fora post* [here](https://urbit.org/fora/posts/~2016.12.29..19.37.08..89d5~/).
15##### Reading guide
17Headings 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.
19Want 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.
21## . dot (nock)
23Anything Nock can do, Hoon can do also.
25### .+ dotlus
27[docs](../rune/dot/lus/) \\+
28`[%dtls p=atom]`: increment an atom with Nock 4.
30R: `.+(p)`
31I: `+(p)`
33### .= dottis
35[docs](../rune/dot/tis/) \\=
36`[%dtls p=hoon q=hoon]`: test for equality with Nock 5.
38R: `.=(p q)`
39I: `=(p q)`
41## ; mic (make)
43Miscellaneous useful macros.
45### ;: miccol
47[docs](../rune/mic/col/) \\:
48`[%smcl p=hoon q=(list hoon)]`: call a binary function as an n-ary function.
50R: `;:(p q)`
51I: `:(p q)`
53## : col (cells)
55The cell runes.
57### :- colhep
59[docs](../rune/col/hep/) \\[\\]\\^\\+\\\`\\~
60`[%clhp p=hoon q=hoon]`: construct a cell (2-tuple).
62R: `:-(p q)`
63I:
65```
66 [a b] ==> :-(a b)
67[a b c] ==> [a [b c]]
68 a^b^c ==> [a b c]
69 a/b ==> [%a b]
70 `a ==> [~ a]
71 ~[a b] ==> [a b ~]
72 [a b]~ ==> [[a b] ~]
73```
75## = tis (flow)
77Flow hoons change the subject. All non-flow hoons (except cores) pass the subject down unchanged.
79### =< tisgar
81[docs](../rune/tis/gal/) \\:
82`[%tsgl p=hoon q=hoon]`: compose two hoons, inverted.
84R: `=<(p q)`
85I: `p:q`
87## | bar (core)
89[docs](../rune/bar/) \\$
90Core hoons are flow hoon.
92Technically not irregular syntax, but worth mentioning.
94- `|= bartis`
95- `|. bardot`
96- `|- barhep`
97- `|* bartar`
99The 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: `$()`.
101## % cen (call)
103The invocation family of runes.
105### %= centis
107[docs](../rune/cen/tis/) \\(\\)
108`[%cnts p=wing q=(list (pair wing hoon))]`: take a wing with changes.
110R: `%=(p a 1)`
111I: `p(a 1)`
113### %~ censig
115[docs](../rune/cen/sig/) \\~
116`[%cnsg p=wing q=hoon r=hoon]`: call with multi-armed door.
118R: `%~(p q r)`
119I: `~(p q r)`
121### %- cenhep
123[docs](../rune/cen/hep/) \\(\\)
124`[%cnhp p=hoon q=hoon]`: call a gate (function).
126R: `%-(p q)`
127I: `(p q)`
129Note: `(p)` becomes `$:p` (`=<($ p)`), which behaves as you would expect (func call w/o args).
131## $ buc (mold)
133A mold is a gate (function) that helps us build simple and rigorous data structures.
135### $? bucwut
137[docs](../rune/buc/wut/) \\?
138`[%bcwt p=(list model)]`: mold which normalizes a general union.
140R: `$?(p)`
141I: `?(p)`
143### $_ buccab
145[docs](../rune/buc/cab/) \\_
146`[%bccb p=value]`: mold which normalizes to an example.
148R: `$_(p)`
149I: `_p`
151## ? wut (test)
153Hoon has the usual branches and logical tests.
155### ?! wutzap
157[docs](../rune/wut/zap/) \\!
158`[%wtzp p=hoon]`: logical not.
160R: `?!(p)`
161I: `!(p)`
163### ?& wutpam
165[docs](../rune/wut/pam/) \\&
166`[%wtpm p=(list hoon)]`: logical and.
168R: `?&(p)`
169I: `&(p)`
171### ?| wutbar
173[docs](../rune/wut/bar/) \\|
174`[%wtbr p=(list hoon)]`: logical or.
176R: `?|(p)`
177I: `|(p)`
179## ^ ket (cast)
181Lets us adjust types without violating type constraints.
183### ^- kethep
185[docs](../rune/ket/hep/) \\\`
186`[%kthp p=model q=value]`: typecast by mold.
188R: `^-(p q)`
189I: `` `p`q ``
191### ^= kettis
193[docs](../rune/ket/tis/) \\=
194`[%ktts p=toga q=value]`: name a value.
196R: `^=(p q)`
197I: `p=q`
199## Miscellaneous
201### Trivial molds
203\\*\\^\\?
205- `*` noun.
206- `@` atom.
207- `^` cell.
208- `?` loobean.
209- `~` null.
211### Values
213\\~\\-\\.\\&\\|
215- `~` null.
216- `&` loobean true.
217- `|` loobean false.
218- `%a` constant `a`, where `a` can be an ((ir)regularly defined) atom or a symbol.
220See [%sand](../rune/constant/warm) for other irregular definitions of atoms.
222### List addressing
224- `&n` nth element of a list.
225- `|n` tail of list after nth element (i.e. n is the head).
227### Limbs
229[docs](../rune/limb/limb/) \\+\\.\\^
230`[%limb p=(each @ud [p=@ud q=@tas])]`: attribute of subject.
232- `+15` is slot 15
233- `.` is the whole subject (slot 1)
234- `^a` is the `a` "of a higher scope", i.e. "resolve variable a, ignoring the first one found".
235- `^^p` even higher, etc.
236- 'Lark' syntax for slots / tree addressing:
237```
238+1
239+2 -
240+3 +
241+4 -<
242+5 ->
243+6 +<
244+7 +>
245+8 -<-
246...
247```
250### Wings
252[docs](../rune/limb/wing/)
253`[%wing p=(list limb)]`; a limb search path.
254`a.b` finds limb `a` within limb `b` ("var" `a` within "var" `b`).
256### Printing stuff
258- `<a b c>` prints a [tape](../library/2q/#-tape).
259- `>a b c<` prints a [tank](../library/2q/#-tank).
261## Commentary
263In 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.
265##### If we missed any, or if you saw something weird that's not in here, feel free to comment below!