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 :-
.
:-
"colhep"
Construct a cell (2-tuple).
Syntax
Two arguments, fixed.
Form | Syntax |
---|---|
Tall |
|
Wide |
|
Irregular #1 |
|
Irregular #2 |
|
AST
[%clhp p=hoon q=hoon]
Produces
The cell of p
and q
.
Discussion
Hoon expressions actually use the same "autocons" pattern as Nock formulas. If you're assembling expressions (which usually only the compiler does), [a b]
is the same as :-(a b)
.
Examples
> :-(1 2)[1 2]~zod:dojo> 1^2[1 2]
:_
"colcab"
Construct a cell, inverted.
Syntax
Two arguments, fixed.
Form | Syntax |
---|---|
Tall |
|
Wide |
|
Irregular | None. |
AST
[%clcb p=hoon q=hoon]
Expands to
:-(q p)
Examples
> :_(1 2)[2 1]
:+
"collus"
Construct a triple (3-tuple).
Syntax
Three arguments, fixed.
Form | Syntax |
---|---|
Tall |
|
Wide |
|
Irregular |
|
AST
[%clls p=hoon q=hoon r=hoon]
Expands to:
:-(p :-(q r))
Examples
> :+ 123[1 2 3]> :+(%a ~ 'b')[%a ~ 'b']
:^
"colket"
Construct a quadruple (4-tuple).
Syntax
Four arguments, fixed.
Form | Syntax |
---|---|
Tall |
|
Wide |
|
Irregular |
|
AST
[%clkt p=hoon q=hoon r=hoon s=hoon]
Expands to
:-(p :-(q :-(r s)))
Examples
> :^(1 2 3 4)[1 2 3 4]> :^ 5678[5 6 7 8]
:*
"coltar"
Construct an n-tuple.
Syntax
Variable number of arguments.
Form | Syntax |
---|---|
Tall |
|
Wide |
|
Irregular |
|
AST
[%cltr p=(list hoon)]
Expands to
Pseudocode: a
, b
, c
, ... as elements of p
:
:-(a :-(b :-(c :-(... z)))))
Desugaring
|-?~ p!!?~ t.pi.p:- i.p$(p t.p)
Examples
> :*(5 3 4 1 4 9 0 ~ 'a')[5 3 4 1 4 9 0 ~ 'a']> [5 3 4 1 4 9 0 ~ 'a'][5 3 4 1 4 9 0 ~ 'a']> :* 5341490~'a'==[5 3 4 1 4 9 0 ~ 'a']
:~
"colsig"
Construct a null-terminated list.
Syntax
Variable number of arguments.
Form | Syntax |
---|---|
Tall |
|
Wide |
|
Irregular |
|
AST
[%clsg p=(list hoon)]
Expands to
Pseudocode: a
, b
, c
, ... as elements of p
:
:-(a :-(b :-(c :-(... :-(z ~)))))
Desugaring
|-?~ p~:- i.p$(p t.p)
Discussion
Note that this does not produce a list
type, it just produces a null-terminated n-tuple. To make it a proper list
it must be cast or molded.
Examples
> :~(5 3 4 2 1)[5 3 4 2 1 ~]> ~[5 3 4 2 1][5 3 4 2 1 ~]> :~ 53421==[5 3 4 2 1 ~]
::
"colcol"
Code comment.
Syntax
:: any text you like!
Examples
:::: this is commented code::|= a=@ :: a gate(add 2 a) :: that adds 2:: to the input