on 492ae2f help sign in
49 lines 1.2 kB history raw
1### `++perk`
3Parse cube with fork
5Parser generator. Produces a parser that succeeds upon encountering one
6of the [`++term`]()s in a faceless list `a`.
8A perk is an arm used to parse one of a finite set of options, formally
9a choice between [`++term`]()s: if you want to match "true" or "false", and
10nothing else, (perk \~[%true %false]) produces the relevant parser,
11whose result type is `?(%true %false)`. For more complicated
12transformations, a combintation of ++[`++sear`]() and map ++[`++get`]() is recommended,
13e.g. `(sear ~(get by (mo ~[[%true &] [%false |]]))) sym)` will have a
14similar effect but produce `?(& |)` , a [boolean](). However, constructions
15such as `(sear (flit ~(has in (sa %true %false %other ~))) sym)` are
16needlessly unwieldy.
18Accepts
19-------
21`a` is a [`++pole`](), which is a [`++list`]() without [`%face`]()s.
23Produces
24--------
26XX
28Source
29------
31 ++ perk :: parse cube with fork
32 |* a=(pole ,@tas)
33 ?~ a fail
34 ;~ pose
35 (cold -.a (jest -.a))
36 $(a +.a)
37 ==
38 ::
40Examples
41--------
43 ~zod/try=> (scan "ham" (perk %sam %ham %lam ~))
44 %ham
45 ~zod/try=> (scan "ram" (perk %sam %ham %lam ~))
46 ! {1 1}
47 ! exit