@@ -8,29 +8,26 @@ navhome: /docs/
9Unpack atom to noun
9Unpack atom to noun
11−Produces a noun unpacked from atom `a`. The inverse of jam.
11+Produces a noun unpacked from atom `a`. The inverse of `jam`.
13−Accepts
13+#### Accepts
16`a` is an atom.
15`a` is an atom.
18−Produces
17+#### Produces
26− ++ cue :: unpack
23+ ++ cue
31 =+ m=`(map @ *)`~
28 =+ m=`(map @ *)`~
33− |- ^- {p/@ q/* r/(map @ *)}
30+ |- ^- [p=@ q=* r=(map @ *)]
34 ?: =(0 (cut 0 [b 1] a))
31 ?: =(0 (cut 0 [b 1] a))
35 =+ c=(rub +(b) a)
32 =+ c=(rub +(b) a)
36 [+(p.c) q.c (~(put by m) b q.c)]
33 [+(p.c) q.c (~(put by m) b q.c)]
@@ -42,18 +39,18 @@ Source
42 [(add 2 (add p.u p.v)) w (~(put by r.v) b w)]
39 [(add 2 (add p.u p.v)) w (~(put by r.v) b w)]
43 =+ d=(rub c a)
40 =+ d=(rub c a)
44 [(add 2 p.d) (need (~(get by m) q.d)) m]
41 [(add 2 p.d) (need (~(get by m) q.d)) m]
48−Examples
43+#### Examples
51 > (cue 12)
45 > (cue 12)
53 > (cue 817)
48 > (cue 817)
55 > (cue 4.657)
51 > (cue 4.657)
57 > (cue 39.689)
54 > (cue 39.689)
@@ -63,29 +60,26 @@ Examples
64Pack noun to atom
61Pack noun to atom
66−Produces an atom packed from noun `a`. The inverse of cue.
63+Produces an atom packed from noun `a`. The inverse of `cue`.
68−Accepts
65+#### Accepts
71`a` is a noun.
67`a` is a noun.
73−Produces
69+#### Produces
81− ++ jam :: pack
75+ ++ jam
86 =+ m=`(map * @)`~
80 =+ m=`(map * @)`~
88− |- ^- {p/@ q/@ r/(map * @)}
82+ |- ^- [p=@ q=@ r=(map * @)]
89 =+ c=(~(get by m) a)
83 =+ c=(~(get by m) a)
91 => .(m (~(put by m) a b))
85 => .(m (~(put by m) a b))
@@ -101,18 +95,19 @@ Source
101 [(add 1 p.d) (lsh 0 1 q.d) m]
95 [(add 1 p.d) (lsh 0 1 q.d) m]
102 =+ d=(mat u.c)
96 =+ d=(mat u.c)
103 [(add 2 p.d) (mix 3 (lsh 0 2 q.d)) m]
97 [(add 2 p.d) (mix 3 (lsh 0 2 q.d)) m]
107−Examples
100+#### Examples
110 > (jam 1)
102 > (jam 1)
112 > (jam [1 1])
105 > (jam [1 1])
114 > (jam [1 2])
108 > (jam [1 2])
116 > (jam [~ u=19])
111 > (jam [~ u=19])
@@ -127,49 +122,50 @@ Produces a cell whose tail `q` is atom `a` with a bit representation of
127its length prepended to it (as the least significant bits). The head `p`
122its length prepended to it (as the least significant bits). The head `p`
128is the length of `q` in bits.
123is the length of `q` in bits.
130−Accepts
125+#### Accepts
133`a` is an atom.
127`a` is an atom.
135−Produces
129+#### Produces
138−A cell of two atoms, `p` and `q`.
131+A cell of two atom.
140−Source
133+#### Source
143− ++ mat :: length-encode
135+ ++ mat
146− ^- {p/@ q/@}
138+ ^- [p=@ q=@]
147 ?: =(0 a)
139 ?: =(0 a)
149 =+ b=(met 0 a)
141 =+ b=(met 0 a)
150 =+ c=(met 0 b)
142 =+ c=(met 0 b)
151 :- (add (add c c) b)
143 :- (add (add c c) b)
152 (cat 0 (bex c) (mix (end 0 (dec c) b) (lsh 0 (dec c) a)))
144 (cat 0 (bex c) (mix (end 0 (dec c) b) (lsh 0 (dec c) a)))
156−Examples
146+#### Examples
159 > (mat 0xaaa)
148 > (mat 0xaaa)
160 [p=20 q=699.024]
149 [p=20 q=699.024]
161 > (met 0 q:(mat 0xaaa))
151 > (met 0 q:(mat 0xaaa))
163 > `@ub`q:(mat 0xaaa)
154 > `@ub`q:(mat 0xaaa)
164 0b1010.1010.1010.1001.0000
155 0b1010.1010.1010.1001.0000
165 > =a =-(~&(- -) `@ub`0xaaa)
157 > =a =-(~&(- -) `@ub`0xaaa)
166 0b1010.1010.1010
158 0b1010.1010.1010
167 > =b =-(~&(- -) `@ub`(xeb a))
160 > =b =-(~&(- -) `@ub`(xeb a))
169 > =b =-(~&(- -) `@ub`(met 0 a))
163 > =b =-(~&(- -) `@ub`(met 0 a))
171 > =c =-(~&(- -) (xeb b))
166 > =c =-(~&(- -) (xeb b))
173 > [`@ub`a `@ub`(end 0 (dec c) b) `@ub`(bex c)]
169 > [`@ub`a `@ub`(end 0 (dec c) b) `@ub`(bex c)]
174 [0b1010.1010.1010 0b100 0b1.0000]
170 [0b1010.1010.1010 0b100 0b1.0000]
@@ -183,27 +179,24 @@ Length-decode
183The inverse of `++mat`. Accepts a cell of index `a` and a bitstring `b`
179The inverse of `++mat`. Accepts a cell of index `a` and a bitstring `b`
184and produces the cell whose tail `q` is the decoded atom at index `a`
180and produces the cell whose tail `q` is the decoded atom at index `a`
185and whose head is the length of the encoded atom `q`, by which the
181and whose head is the length of the encoded atom `q`, by which the
186−offset `a` is advanced. Only used internally as a helper cue.
182+offset `a` is advanced.
188−Accepts
184+#### Accepts
191`a` is an atom.
186`a` is an atom.
193`b` is a bitstring as an atom.
188`b` is a bitstring as an atom.
195−Produces
190+#### Produces
198−A cell of two atoms, `p` and `q`.
192+A cell of two atoms.
200−Source
194+#### Source
203− ++ rub :: length-decode
196+ ++ rub
205− |= {a/@ b/@}
198+ |= [a=@ b=@]
206− ^- {p/@ q/@}
199+ ^- [p=@ q=@]
208 =+ [c=0 m=(met 0 b)]
201 =+ [c=0 m=(met 0 b)]
209 |- ?< (gth c m)
202 |- ?< (gth c m)
@@ -217,14 +210,20 @@ Source
217 [(add (add c c) e) (cut 0 [(add d (dec c)) e] b)]
210 [(add (add c c) e) (cut 0 [(add d (dec c)) e] b)]
220−Examples
213+#### Examples
223 > `@ub`(jam 0xaaa)
215 > `@ub`(jam 0xaaa)
224 0b1.0101.0101.0101.0010.0000
216 0b1.0101.0101.0101.0010.0000
225 > (rub 1 0b1.0101.0101.0101.0010.0000)
218 > (rub 1 0b1.0101.0101.0101.0010.0000)
226 [p=20 q=2.730]
219 [p=20 q=2.730]
227 > `@ux`q:(rub 1 0b1.0101.0101.0101.0010.0000)
221 > `@ux`q:(rub 1 0b1.0101.0101.0101.0010.0000)
227+Only used internally as a helper cue.