on 140ac0e help sign in
51 lines 1.0 kB history raw
1### `++comp`
3Arbitrary compose
5Parsing composer: connects the `++edge` `vex` with a following `++rule` `sab`,
6combining the contents of `vex` with the result of `sab` using a binary
7gate `raq`. Used to fold over the results of several `++rules`.
9Accepts
10-------
12`raq` is a gate that accepts a cell of two nouns, `a` and `b`, and
13produces a cell of two nouns.
15`sab` is a rule.
17`vex` is an edge.
19Produces
20--------
22A `++rule`.
24Source
25------
27 ++ comp
28 ~/ %comp
29 |* raq/_|*({a/* b/*} [a b]) :: arbitrary compose
30 ~/ %fun
31 |* {vex/edge sab/rule}
32 ~! +<
33 ?~ q.vex
34 vex
35 =+ yit=(sab q.u.q.vex)
36 =+ yur=(last p.vex p.yit)
37 ?~ q.yit
38 [p=yur q=q.yit]
39 [p=yur q=[~ u=[p=(raq p.u.q.vex p.u.q.yit) q=q.u.q.yit]]]
40 ::
42Examples
43--------
45 ~zod/try=> (scan "123" ;~((comp |=([a/@u b/@u] (add a b))) dit dit dit))
46 6
47 ~zod/try=> (scan "12" ;~((comp |=([a/@u b/@u] (add a b))) dit dit dit))
48 ! {1 3}
49 ! exit
51***