on 492ae2f help sign in
46 lines 665 B history raw
1### `++cap`
3Tree head
5Tests whether an `a` is in the head or tail of a noun. Produces the
6cube `%2` if it is within the head, or the cube `%3` if it is
7within the tail.
9Accepts
10-------
12`a` is an atom.
14Produces
15--------
17A cube.
19Source
20------
22 ++ cap :: tree head
23 ~/ %cap
24 |= a=@
25 ^- ?(%2 %3)
26 ?- a
27 %2 %2
28 %3 %3
29 ?(%0 %1) !!
30 * $(a (div a 2))
31 ==
32 ::
34Examples
35--------
37 ~zod/try=> (cap 4)
38 %2
39 ~zod/try=> (cap 6)
40 %3
41 ~zod/try=> (cap (add 10 9))
42 %2
46***