@@ -881,6 +881,132 @@ Examples
887+Gate to list, with state
889+Accepts a `++list` `a`, a gate `b`, and some state `c`. Produces a list with
890+the gate applied to each element of the original list. `b` is called with
891+a tuple -- the head is an element of `a` and the tail is the state `c`, and
892+should produce a tuple of the transformed element and the (potentially
913+ |* {a/(list) b/_|=({* *} [** +<+]) c/*}
914+ :: ?< ?=($-([_?<(?=($~ a) i.a) _c] [* _c]) b)
919+ [i=-.v t=$(a t.a, c +.v)]
925+A trivial example -- does nothing with the state:
927+ > %^ spin (limo ~[4 5 6])
932+Create a list of pairs, `p` as the index and `q` as the list element:
934+ > %^ spin (limo ~[4 5 6])
935+ |=({n/@ a/@} [`(pair)`[a n] +(a)])
937+ ~[[p=0 q=4] [p=1 q=5] [p=2 q=6]]
939+Create 10 random numbers less than `10`:
941+ > %^ spin (reap 10 0)
942+ |=({n/@ rng/_og} (rads:rng 10))
944+ ~[5 5 9 4 1 7 9 9 9 6]
948+`(~(rads og eny) 2)` creates a random number less than `2`, seeding the RNG
949+with entropy (`eny`). The head of the product is the random number, the tail
950+is the continuation of the RNG.
957+Gate to list, with state
959+Accepts a `++list` `a` and a gate `b`. `c` is internal state, initially
960+derived by *bunting* the tail of the sample of gate `b`, instead of
961+being passed in explicitly as in `++spin`. Produces a list with the
962+gate applied to each element of the original list. `b` is called with a tuple
963+-- the head is an element of `a` and the tail is the state `c`, and should
964+produce a tuple of the transformed element and the (potentially modified)
983+ |* {a/(list) b/_|=({* *} [** +<+])}
989+ [i=-.v t=$(a t.a, c +.v)]
995+Create a list of pairs, `p` as the index and `q` as the list element:
997+ > %+ spun (limo ~[4 5 6])
998+ |=({n/@ a/@} [`(pair)`[a n] +(a)])
999+ ~[[p=0 q=4] [p=1 q=5] [p=2 q=6]]
1001+Join two lists into a list of pairs, `p` from `l` and `q` from the sample:
1003+ > =l (limo ~[7 8 9])
1004+ > %+ spun (limo ~[4 5 6])
1005+ |=({n/@ a/@} [`(pair)`[(snag a l) n] +(a)])
1006+ ~[[p=7 q=4] [p=8 q=5] [p=9 q=6]]
885### `++weld`
1011### `++weld`