on 492ae2f help sign in
46 lines 819 B history raw
1### `++reel`
3Right fold
5Right fold: moves right to left across a `++list` `a`, recursively slamming
6a binary gate `b` with an element from `a` and an accumulator, producing
7the final value of the accumulator.
9Accepts
10-------
12`b` is a binary gate.
14Produces
15--------
17The accumulator, which is a noun.
19Source
20------
22 ++ reel :: right fold
23 ~/ %reel
24 |* {a/(list) b/_|=({* *} +<+)}
25 |- ^+ +<+.b
26 ?~ a
27 +<+.b
28 (b i.a $(a t.a))
31Examples
32--------
34 ~zod/try=> =sum =|([p=@ q=@] |.((add p q)))
35 ~zod/try=> (reel (limo [1 2 3 4 5 ~]) sum)
36 15
37 ~zod/try=> =a =|([p=@ q=@] |.((sub p q)))
38 ~zod/try=> (reel (limo [6 3 1 ~]) a)
39 4
40 ~zod/try=> (reel (limo [3 6 1 ~]) a)
41 ! subtract-underflow
42 ! exit
46***