!!
puzzles-2
=| steps=@ =/ n 6 |- ?: =(n 1) steps =/ next=@ ?: =(0 (mod n 2)) (div n 2) (add (mul 3 n) 1) $(n next, steps (add steps 1))

hailstones

glossary

=| pins a name at its type's default value (its bunt) - often an accumulator starting at zero.

=|(n=@ n) is 0.

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

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

=/ 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.

|- makes a trap and runs it at once.

inside, $ restarts it with new values - this is how you loop.

=/(a 3 |-(?:(=(a 0) 7 $(a (dec a))))) is 7.

?: is if-then-else: it picks its first branch when the test is yes, the second when no.

?:((gth 3 5) 10 20) is 20.

.= tests two nouns for equality, giving a loobean.

.=(3 3) is %.y, and .=(3 4) is %.n.

irregular forms:

=(a b) is .=(a b)

%: calls a gate with several arguments, gathering them into one sample.

%:(add 2 3) is 5.

irregular forms:

(gate a b c) is %:(gate a b c)

mod is the remainder of a division.

(mod 17 5) is 2.

div divides, discarding the remainder.

(div 17 5) is 3.

add sums two atoms.

(add 2 3) is 5.

mul multiplies two atoms.

(mul 3 4) is 12.

%= 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