@@ -2,42 +2,20 @@
5−`|% barcen`
5+# `:core, |%, "buccab", {$shoe p/twig}`
8Generic core.
7Generic core.
10−Constructs a generic core with n named expressions, closed with `--`. Cores are
9+Produces: a core with `p`, an associative array with `++term` keys and `++foot` values.
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.
13−Produces
11+Regular form: *Battery*
16−Twig: `[%brcn p=(map term foot)]`
13+Example:
21−`p` is a [`++map`]() with [`++term`]() keys and [`++foot`]() values, which
37 /~zod/try=>
15 /~zod/try=>
40− ++ g |= b=@
18+ ++ g |= b/@
43 new var %a
21 new var %a
@@ -54,7 +32,7 @@ function. `g` adds our constant `n` to whatever is passed to it.
57− ++ g |= b=@
35+ ++ g |= b/@
58 (div (add b r:l) s:l)
36 (div (add b r:l) s:l)
60 changed %a
38 changed %a
@@ -67,36 +45,19 @@ and make our function `g` a bit more complicated. `g` now computes the
67sum of its argument and the arm `r` inside `l`, and divides that by `s`
45sum of its argument and the arm `r` inside `l`, and divides that by `s`
68inside `l`.
46inside `l`.
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)
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)
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.
87 ++ si :: signed integer
48 ++ si :: signed integer
89− ++ abs |=(a=@s (add (end 0 1 a) (rsh 0 1 a)))
50+ ++ 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))))
51+ ++ 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))))
52+ ++ dul |=([a/@s b/@] =+(c=(old a) ?:(-.c (mod +.c b) (sub b +.c))))
92− ++ fra |= [a=@s b=@s]
53+ ++ fra |= [a/@s b/@s]
93 (new =(0 (mix (syn a) (syn b))) (div (abs a) (abs b)))
54 (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))))))
55+ ++ new |=([a/? b/@] `@s`?:(a (mul 2 b) ?:(=(0 b) 0 +((mul 2 (dec b))))))
95− ++ old |=(a=@s [(syn a) (abs a)])
56+ ++ old |=(a/@s [(syn a) (abs a)])
96− ++ pro |= [a=@s b=@s]
57+ ++ pro |= [a/@s b/@s]
97 (new =(0 (mix (syn a) (syn b))) (mul (abs a) (abs b)))
58 (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))))
59+ ++ rem |=([a/@s b/@s] (dif a (pro b (fra a b))))
99− ++ sum |= [a=@s b=@s]
60+ ++ sum |= [a/@s b/@s]
100 ~| %si-sum
61 ~| %si-sum
101 =+ [c=(old a) d=(old b)]
62 =+ [c=(old a) d=(old b)]
@@ -110,10 +71,10 @@ shows, `|%` is also used to encapsulate arms that perform calculations.
110 (new | (sub +.c +.d))
71 (new | (sub +.c +.d))
111 (new & (sub +.d +.c))
72 (new & (sub +.d +.c))
112 (new | (add +.c +.d))
73 (new | (add +.c +.d))
113− ++ sun |=(a=@u (mul 2 a))
74+ ++ sun |=(a/@u (mul 2 a))
114− ++ syn |=(a=@s =(0 (end 0 1 a)))
75+ ++ syn |=(a/@s =(0 (end 0 1 a)))
117−[`++si`](), found in `hoon.hoon`, uses `|%` to create a core whose arms
78+`++si`, found in `hoon.hoon`, uses `|%` to create a core whose arms
118−contain functions used to calculate with signed integers, [`@s`](). In this
79+contain functions used to calculate with signed integers, `@s`. In this
119case our core is made up entirely of functions.
80case our core is made up entirely of functions.