!!
puzzles-3
=/ items `(list (unit @))`~[`1 ~ `3 ~ `5] %- lent %+ skim items |= x=(unit @) ?= ^ x

survivors

glossary

=/ pins a named value (a face) into the subject for the lines below it.

name=value optionally declares the type.

=/(a 3 (add a a)) is 6.

^- 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 ~.

unit is the maybe type: either ~ or [~ value].

(unit @) holds an atom or nothing.

:~ makes a null-terminated list.

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

irregular forms:

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

%- calls a gate on one argument (or one cell of arguments).

%-(dec 8) is 7.

irregular forms:

(gate arg) is %-(gate arg)

lent is how many elements a list has.

(lent `(list @)`~[8 9 10]) is 3.

%+ calls a gate that takes two arguments.

%+(add 2 3) is 5.

irregular forms:

(gate a b) is %+(gate a b)

skim keeps the list elements a gate says yes to.

(skim `(list @)`~[1 2 3 4] |=(n=@ (gth n 2))) is ~[3 4].

|= makes a gate: a function with one named sample, then a body.

the body runs with the sample bound.

call the gate to run it.

(|=(a=@ (add a 1)) 4) is 5.

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

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

?= tests whether a value matches a shape, giving a loobean.

?=(^ [1 2]) is %.y.