: col · Cells

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.

:-  p
q

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.

AST

Expands to

Examples


:+ "collus"

Construct a triple (3-tuple).

Syntax

Three arguments, fixed.

AST

Expands to:

Examples


:^ "colket"

Construct a quadruple (4-tuple).

Syntax

Four arguments, fixed.

AST

Expands to

Examples


:* "coltar"

Construct an n-tuple.

Syntax

Variable number of arguments.

AST

Expands to

Pseudocode: a, b, c, ... as elements of .p:

Desugaring

Examples


:~ "colsig"

Construct a null-terminated list.

Syntax

Variable number of arguments.

AST

Expands to

Pseudocode: a, b, c, ... as elements of .p:

Desugaring

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


:: "colcol"

Code comment.

Syntax

Examples

Last updated