maps and sets

spin is turn with state: its gate takes an item and the state, and produces a new item and the next state. it produces both the list and the final state.

produce the running total after each order.

=> |% +$ order [who=@t item=@t count=@ud] ++ orders ^- (list order) :~ ['ted' 'tea' 2] ['ann' 'cake' 1] ['ted' 'cake' 3] ['bo' 'tea' 1] == --
glossary

=> sets the subject to its head, then evaluates its tail against it.

=>([a=1 b=2] b) is 2.

|% makes a core: a battery of named arms, each written ++ name.

reach an arm back out with =< or arm:core.

=<  a
|%
++  a  5
--

is 5.

^: turns a type into a factory gate that molds any noun to that type.

(^:(@ud) 5) is 5.

$: makes a tuple mold, naming each face in a cell.

$:(x=@ y=@) is the mold [x=@ y=@].

$= wraps a mold with a face, naming the value it produces.

$=(x @) is the mold x=@.

^- casts a value to a named type: it checks the value fits and relabels it.

^-(@ 42) is 42.

irregular forms:

a leading backtick cast - the type in backticks, then the value - is ^-

list is the type of a null-terminated sequence.

(list @) is a list of atoms; the empty list is ~.

:~ makes a null-terminated list.

:~(1 2 3) is ~[1 2 3].

irregular forms:

~[a b c] is :~(a b c)

:* makes a tuple of many elements, nesting to the right.

:*(1 2 3) is [1 2 3].

irregular forms:

[a b c d] is :*(a b c d)

%= resolves a wing with some faces changed.

=/(a [x=1 y=2] a(x 9)) is [x=9 y=2].

irregular forms:

a(x 9) is %=(a x 9)

$(a b) restarts a loop with a changed to b