@@ -4,242 +4,403 @@ weight = 9
4template = "doc.html"
4template = "doc.html"
5aliases = ["docs/reference/hoon-expressions/rune/col/"]
5aliases = ["docs/reference/hoon-expressions/rune/col/"]
7−The `:` ("col") expressions are used to produce cells, which are pairs of values. E.g., `:-(p q)` produces the cell `[p q]`. All `:` runes reduce to `:-`.
9−## Runes
8+The `:` ("col") expressions are used to produce cells, which are pairs of
9+values. E.g., `:-(p q)` produces the cell `[p q]`. All `:` runes reduce to `:-`.
11−### `:_` "colcab"
11+## `:-` "colhep"
13−`[%clcb p=hoon q=hoon]`; construct a cell, inverted.
13+Construct a cell (2-tuple).
15−##### Expands to
15+#### Syntax
21−##### Syntax
26+Wide form:
23−Regular: **2-fixed**.
28+```hoon
25−##### Examples
32+Irregular form:
32−### `::` "colcol"
44+#### AST
34−Code comment
46+```hoon
36−##### Syntax
50+#### Produces
38−:: any text you like!
52+The cell of `p` and `q`.
56+Hoon expressions actually use the same "autocons" pattern as Nock
57+formulas. If you're assembling expressions (which usually only the
58+compiler does), `[a b]` is the same as `:-(a b)`.
74+Construct a cell, inverted.
44−:: this is commented code
84+q
47−(add 2 a) :: that adds 2
51−### `:-` "colhep"
87+Wide form:
53−`[%clhp p=hoon q=hoon]`: construct a cell (2-tuple).
89+```hoon
55−##### Produces
93+Irregular form:
57−The cell of `p` and `q`.
95+None.
59−##### Syntax
97+#### AST
61−Regular: **2-fixed**.
99+```hoon
100+[%clcb p=hoon q=hoon]
63−Irregular: `[a b]` is `:-(a b)`.
103+#### Expands to
65−Irregular: `[a b c]` is `[a [b c]]`.
105+```hoon
67−Irregular: `a^b^c` is `[a b c]`.
109+#### Examples
69−Irregular: `a/b` is `[%a b]`.
111+```
71−Irregular: `` `a `` is `[~ a]`.
116+---
73−Irregular: `~[a b]` is `[a b ~]`.
118+## `:+` "collus"
75−Irregular: `[a b c]~` is `[[a b c] ~]`.
120+Construct a triple (3-tuple).
77−## Discussion
122+#### Syntax
79−Hoon expressions actually use the same "autocons" pattern as Nock
124+Three arguments, fixed.
80−formulas. If you're assembling expressions (which usually only the
81−compiler does), `[a b]` is the same as `:-(a b)`.
83−##### Examples
126+Tall form:
89−~zod:dojo> 1^2
134+Wide form:
92−~zod:dojo> 1/2
136+```hoon
95−~zod:dojo> `1
140+Irregular form:
99−### `:^` "colket"
146+#### AST
101−`[%clkt p=hoon q=hoon r=hoon s=hoon]`: construct a quadruple (4-tuple).
149+[%clls p=hoon q=hoon r=hoon]
103−##### Expands to
152+#### Expands to:
106−:-(p :-(q :-(r s)))
155+:-(p :-(q r))
109−##### Syntax
158+#### Examples
111−Regular: **4-fixed**.
160+```
113−##### Examples
172+## `:^` "colket"
174+Construct a quadruple (4-tuple).
178+Four arguments, fixed.
116−~zod:dojo> :^(1 2 3 4)
119−~zod:dojo> :^ 5
189+Wide form:
126−### `:+` "collus"
195+Irregular form:
129−`[%clls p=hoon q=hoon r=hoon]`: construct a triple (3-tuple).
204+[%clkt p=hoon q=hoon r=hoon s=hoon]
131−##### Expands to:
207+#### Expands to
134−:-(p :-(q r))
210+:-(p :-(q :-(r s)))
230+Construct an n-tuple.
137−##### Syntax
232+#### Syntax
139−Regular: **3-fixed**.
234+Variable number of arguments.
141−##### Examples
236+Tall form:
149−~zod:dojo> :+(%a ~ 'b')
246+Wide form:
153−### `:~` "colsig"
252+Irregular form:
155−`[%clsg p=(list hoon)]`: construct a null-terminated list.
254+```hoon
261+[%cltr p=(list hoon)]
157−##### Expands to
264+#### Expands to
159**Pseudocode**: `a`, `b`, `c`, ... as elements of `p`:
266**Pseudocode**: `a`, `b`, `c`, ... as elements of `p`:
162−:-(a :-(b :-(c :-(... :-(z ~)))))
269+:-(a :-(b :-(c :-(... z)))))
165−##### Desugaring
272+#### Desugaring
175−##### Syntax
284+#### Examples
177−Regular: **running**.
286+```
287+> :*(5 3 4 1 4 9 0 ~ 'a')
288+[5 3 4 1 4 9 0 ~ 'a']
179−##### Examples
290+> [5 3 4 1 4 9 0 ~ 'a']
291+[5 3 4 1 4 9 0 ~ 'a']
303+[5 3 4 1 4 9 0 ~ 'a']
182−~zod:dojo> :~(5 3 4 2 1)
185−~zod:dojo> ~[5 3 4 2 1]
306+---
188−~zod:dojo> :~ 5
308+## `:~` "colsig"
190− 4
310+Construct a null-terminated list.
314+Variable number of arguments.
197−### `:*` "coltar"
326+Wide form:
199−`[%cltr p=(list hoon)]`: construct an n-tuple.
341+[%clsg p=(list hoon)]
201−##### Expands to
344+#### Expands to
203**Pseudocode**: `a`, `b`, `c`, ... as elements of `p`:
346**Pseudocode**: `a`, `b`, `c`, ... as elements of `p`:
206−:-(a :-(b :-(c :-(... z)))))
349+:-(a :-(b :-(c :-(... :-(z ~)))))
209−##### Desugaring
352+#### Desugaring
221−##### Syntax
362+#### Discussion
223−Regular: **running**.
364+Note that this does not produce a `list` type, it just produces a
365+null-terminated n-tuple. To make it a proper `list` it must be cast or molded.
225−##### Examples
367+#### Examples
228−~zod:dojo> :*(5 3 4 1 4 9 0 ~ 'a')
370+> :~(5 3 4 2 1)
229−[5 3 4 1 4 9 0 ~ 'a']
371+[5 3 4 2 1 ~]
231−~zod:dojo> [5 3 4 1 4 9 0 ~ 'a']
373+> ~[5 3 4 2 1]
232−[5 3 4 1 4 9 0 ~ 'a']
374+[5 3 4 2 1 ~]
234−~zod:dojo> :* 5
376+> :~ 5
244−[5 3 4 1 4 9 0 ~ 'a']
382+[5 3 4 2 1 ~]
394+:: any text you like!
401+:: this is commented code
404+(add 2 a) :: that adds 2