@@ -2,42 +2,20 @@
22sort: 1
33---
44
5−`|% barcen`
6−===========
5+# `:core, |%, "buccab", {$shoe p/twig}`
76
87Generic core.
98
10−Constructs a generic core with n named expressions, closed with `--`. Cores are
11−similar to an object with named properties (aka [arms]()) that can contain either functions or data. Accepts both [dry or `%elm`]() and [wet or `%ash`]() arms.
9+Produces: a core with `p`, an associative array with `++term` keys and `++foot` values.
1210
13−Produces
14−--------
11+Regular form: *Battery*
1512
16−Twig: `[%brcn p=(map term foot)]`
17−
18−Accepts
19−-------
20−
21−`p` is a [`++map`]() with [`++term`]() keys and [`++foot`]() values, which
22−are called arms.
23−
24−Tall form
25−---------
26−
27− |%
28− ++ p.n.q
29− q.n.q
30− +- p.n.l.q
31− q.n.l.q
32− --
33−
34−Examples
35−--------
13+Example:
3614
3715 /~zod/try=>
3816 =a |%
3917 ++ n 100
40− ++ g |= b=@
18+ ++ g |= b/@
4119 (add b n)
4220 --
4321 new var %a
@@ -54,7 +32,7 @@ function. `g` adds our constant `n` to whatever is passed to it.
5432 ++ r 100
5533 ++ s 4
5634 --
57− ++ g |= b=@
35+ ++ g |= b/@
5836 (div (add b r:l) s:l)
5937 --
6038 changed %a
@@ -67,36 +45,19 @@ and make our function `g` a bit more complicated. `g` now computes the
6745sum of its argument and the arm `r` inside `l`, and divides that by `s`
6846inside `l`.
6947
70− ++ yo
71− |% ++ cet 36.524 :: (add 24 (mul 100 365))
72− ++ day 86.400 :: (mul 24 hor)
73− ++ era 146.097 :: (add 1 (mul 4 cet))
74− ++ hor 3.600 :: (mul 60 mit)
75− ++ jes 106.751.991.084.417 :: (mul 730.692.561 era)
76− ++ mit 60
77− ++ moh `(list ,@ud)`[31 28 31 30 31 30 31 31 30 31 30 31 ~]
78− ++ moy `(list ,@ud)`[31 29 31 30 31 30 31 31 30 31 30 31 ~]
79− ++ qad 126.144.001 :: (add 1 (mul 4 yer))
80− ++ yer 31.536.000 :: (mul 365 day)
81− --
82−
83−[`++yo`](), found in `hoon.hoon`, uses `|%` to create a core whose arms
84−contain constant data for calculating time. As the following examples
85−shows, `|%` is also used to encapsulate arms that perform calculations.
86−
8748 ++ si :: signed integer
8849 |%
89− ++ abs |=(a=@s (add (end 0 1 a) (rsh 0 1 a)))
90− ++ dif |=([a=@s b=@s] (sum a (new !(syn b) (abs b))))
91− ++ dul |=([a=@s b=@] =+(c=(old a) ?:(-.c (mod +.c b) (sub b +.c))))
92− ++ fra |= [a=@s b=@s]
50+ ++ abs |=(a/@s (add (end 0 1 a) (rsh 0 1 a)))
51+ ++ dif |=([a/@s b/@s] (sum a (new !(syn b) (abs b))))
52+ ++ dul |=([a/@s b/@] =+(c=(old a) ?:(-.c (mod +.c b) (sub b +.c))))
53+ ++ fra |= [a/@s b/@s]
9354 (new =(0 (mix (syn a) (syn b))) (div (abs a) (abs b)))
94− ++ new |=([a=? b=@] `@s`?:(a (mul 2 b) ?:(=(0 b) 0 +((mul 2 (dec b))))))
95− ++ old |=(a=@s [(syn a) (abs a)])
96− ++ pro |= [a=@s b=@s]
55+ ++ new |=([a/? b/@] `@s`?:(a (mul 2 b) ?:(=(0 b) 0 +((mul 2 (dec b))))))
56+ ++ old |=(a/@s [(syn a) (abs a)])
57+ ++ pro |= [a/@s b/@s]
9758 (new =(0 (mix (syn a) (syn b))) (mul (abs a) (abs b)))
98− ++ rem |=([a=@s b=@s] (dif a (pro b (fra a b))))
99− ++ sum |= [a=@s b=@s]
59+ ++ rem |=([a/@s b/@s] (dif a (pro b (fra a b))))
60+ ++ sum |= [a/@s b/@s]
10061 ~| %si-sum
10162 =+ [c=(old a) d=(old b)]
10263 ?: -.c
@@ -110,10 +71,10 @@ shows, `|%` is also used to encapsulate arms that perform calculations.
11071 (new | (sub +.c +.d))
11172 (new & (sub +.d +.c))
11273 (new | (add +.c +.d))
113− ++ sun |=(a=@u (mul 2 a))
114− ++ syn |=(a=@s =(0 (end 0 1 a)))
74+ ++ sun |=(a/@u (mul 2 a))
75+ ++ syn |=(a/@s =(0 (end 0 1 a)))
11576 --
11677
117−[`++si`](), found in `hoon.hoon`, uses `|%` to create a core whose arms
118−contain functions used to calculate with signed integers, [`@s`](). In this
78+`++si`, found in `hoon.hoon`, uses `|%` to create a core whose arms
79+contain functions used to calculate with signed integers, `@s`. In this
11980case our core is made up entirely of functions.