on 492ae2f help sign in
56 lines 998 B history raw
1### `++stir`
3Parse repeatedly
5Parse with `++rule` as many times as possible, and fold over results with a
6binary gate.
8Accepts
9-------
11`rud` is a noun.
13`raq` is a gate that takes two nouns and produces a cell.
15`fel` is a rule.
17Produces
18--------
20A rule.
22Source
23------
25 ++ stun :: parse several times
26 |* {lig/{@ @} fel/rule}
27 |= tub/nail
28 ^- (like (list _(wonk (fel))))
29 ?: =(0 +.lig)
30 [p.tub [~ ~ tub]]
31 =+ vex=(fel tub)
32 ?~ q.vex
33 ?: =(0 -.lig)
34 [p.vex [~ ~ tub]]
35 vex
36 =+ ^= wag %= $
37 -.lig ?:(=(0 -.lig) 0 (dec -.lig))
38 +.lig ?:(=(0 +.lig) 0 (dec +.lig))
39 tub q.u.q.vex
40 ==
41 ?~ q.wag
42 wag
43 [p.wag [~ [p.u.q.vex p.u.q.wag] q.u.q.wag]]
46Examples
47--------
49 ~zod/try=> (scan "abc" (stir *@ add prn))
50 294
51 ~zod/try=> (roll "abc" add)
52 b=294
56***