on bfaa358 help sign in
52 lines 1.2 kB history raw
1### `++stun`
3Parse several times
5Parse bounded number of times.
7Accepts
8-------
10`[les=@ mos=@]` is a cell of atoms indicating the bounds.
12`fel` is a `++rule`.
14Produces
15--------
17A `++rule`.
19Source
20------
22 ++ stun :: parse several times
23 |* {lig/{@ @} fel/rule}
24 |= tub/nail
25 ^- (like (list _(wonk (fel))))
26 ?: =(0 +.lig)
27 [p.tub [~ ~ tub]]
28 =+ vex=(fel tub)
29 ?~ q.vex
30 ?: =(0 -.lig)
31 [p.vex [~ ~ tub]]
32 vex
33 =+ ^= wag %= $
34 -.lig ?:(=(0 -.lig) 0 (dec -.lig))
35 +.lig ?:(=(0 +.lig) 0 (dec +.lig))
36 tub q.u.q.vex
37 ==
38 ?~ q.wag
39 wag
40 [p.wag [~ [p.u.q.vex p.u.q.wag] q.u.q.wag]]
42Examples
43--------
45 ~zod/try=> ((stun [5 10] prn) [1 1] "aquickbrownfoxran")
46 [p=[p=1 q=11] q=[~ [p="aquickbrow" q=[p=[p=1 q=11] q="nfoxran"]]]]
47 ~zod/try=> ((stun [5 10] prn) [1 1] "aquickbro")
48 [p=[p=1 q=10] q=[~ [p="aquickbro" q=[p=[p=1 q=10] q=""]]]]
49 ~zod/try=> ((stun [5 10] prn) [1 1] "aqui")
50 [p=[p=1 q=5] q=~]
52***