on 492ae2f help sign in
47 lines 847 B history raw
1### `++clap`
3Apply function to two units
5Applies a binary function `c`--which does not usually accept or produce a `++unit`--
6to the values of two units, `a` and `b`, producing a unit.
8Accepts
9-------
11`a` is a unit.
13`b` is a unit.
15`c` is a function that performs a binary operation.
17Produces
18--------
20A unit.
22Source
23------
25 ++ clap :: combine
26 |* {a/(unit) b/(unit) c/_|=(^ +<-)}
27 ?~ a b
28 ?~ b a
29 [~ u=(c u.a u.b)]
32Examples
33--------
35 ~zod/try=> =u ((unit @t) [~ 'a'])
36 ~zod/try=> =v ((unit @t) [~ 'b'])
37 ~zod/try=> (clap u v |=([a=@t b=@t] (welp (trip a) (trip b))))
38 [~ u="ab"]
39 ~zod/try=> =a ((unit @u) [~ 1])
40 ~zod/try=> =b ((unit @u) [~ 2])
41 ~zod/try=> =c |=([a=@ b=@] (add a b))
42 ~zod/try=> (clap a b c)
43 [~ 3]
47***