@@ -8,29 +8,25 @@ 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
18−Produces
16+#### Produces
26− ++ cue :: unpack
22+ ++ cue
31 =+ m=`(map @ *)`~
27 =+ m=`(map @ *)`~
33− |- ^- {p/@ q/* r/(map @ *)}
29+ |- ^- [p=@ q=* r=(map @ *)]
34 ?: =(0 (cut 0 [b 1] a))
30 ?: =(0 (cut 0 [b 1] a))
35 =+ c=(rub +(b) a)
31 =+ c=(rub +(b) a)
36 [+(p.c) q.c (~(put by m) b q.c)]
32 [+(p.c) q.c (~(put by m) b q.c)]
@@ -42,18 +38,18 @@ Source
42 [(add 2 (add p.u p.v)) w (~(put by r.v) b w)]
38 [(add 2 (add p.u p.v)) w (~(put by r.v) b w)]
43 =+ d=(rub c a)
39 =+ d=(rub c a)
44 [(add 2 p.d) (need (~(get by m) q.d)) m]
40 [(add 2 p.d) (need (~(get by m) q.d)) m]
48−Examples
42+#### Examples
51 > (cue 12)
44 > (cue 12)
53 > (cue 817)
47 > (cue 817)
55 > (cue 4.657)
50 > (cue 4.657)
57 > (cue 39.689)
53 > (cue 39.689)
@@ -63,29 +59,26 @@ Examples
64Pack noun to atom
60Pack noun to atom
66−Produces an atom packed from noun `a`. The inverse of cue.
62+Produces an atom packed from noun `a`. The inverse of `cue`.
68−Accepts
64+#### Accepts
71`a` is a noun.
66`a` is a noun.
73−Produces
68+#### Produces
81− ++ jam :: pack
74+ ++ jam
86 =+ m=`(map * @)`~
79 =+ m=`(map * @)`~
88− |- ^- {p/@ q/@ r/(map * @)}
81+ |- ^- [p=@ q=@ r=(map * @)]
89 =+ c=(~(get by m) a)
82 =+ c=(~(get by m) a)
91 => .(m (~(put by m) a b))
84 => .(m (~(put by m) a b))
@@ -101,22 +94,25 @@ Source
101 [(add 1 p.d) (lsh 0 1 q.d) m]
94 [(add 1 p.d) (lsh 0 1 q.d) m]
102 =+ d=(mat u.c)
95 =+ d=(mat u.c)
103 [(add 2 p.d) (mix 3 (lsh 0 2 q.d)) m]
96 [(add 2 p.d) (mix 3 (lsh 0 2 q.d)) m]
107−Examples
99+#### Examples
110 > (jam 1)
101 > (jam 1)
112 > (jam [1 1])
104 > (jam [1 1])
114 > (jam [1 2])
107 > (jam [1 2])
116 > (jam [~ u=19])
110 > (jam [~ u=19])
115+`mat` is only used internally as a helper to `jam`.
122### `++mat`
118### `++mat`
@@ -127,49 +123,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`
123its length prepended to it (as the least significant bits). The head `p`
128is the length of `q` in bits.
124is the length of `q` in bits.
130−Accepts
126+#### Accepts
133`a` is an atom.
128`a` is an atom.
135−Produces
130+#### Produces
138−A cell of two atoms, `p` and `q`.
132+A cell of two atoms.
140−Source
134+#### Source
143− ++ mat :: length-encode
136+ ++ mat
146− ^- {p/@ q/@}
139+ ^- [p=@ q=@]
147 ?: =(0 a)
140 ?: =(0 a)
149 =+ b=(met 0 a)
142 =+ b=(met 0 a)
150 =+ c=(met 0 b)
143 =+ c=(met 0 b)
151 :- (add (add c c) b)
144 :- (add (add c c) b)
152 (cat 0 (bex c) (mix (end 0 (dec c) b) (lsh 0 (dec c) a)))
145 (cat 0 (bex c) (mix (end 0 (dec c) b) (lsh 0 (dec c) a)))
156−Examples
147+#### Examples
159 > (mat 0xaaa)
149 > (mat 0xaaa)
160 [p=20 q=699.024]
150 [p=20 q=699.024]
161 > (met 0 q:(mat 0xaaa))
152 > (met 0 q:(mat 0xaaa))
163 > `@ub`q:(mat 0xaaa)
155 > `@ub`q:(mat 0xaaa)
164 0b1010.1010.1010.1001.0000
156 0b1010.1010.1010.1001.0000
165 > =a =-(~&(- -) `@ub`0xaaa)
158 > =a =-(~&(- -) `@ub`0xaaa)
166 0b1010.1010.1010
159 0b1010.1010.1010
167 > =b =-(~&(- -) `@ub`(xeb a))
161 > =b =-(~&(- -) `@ub`(xeb a))
169 > =b =-(~&(- -) `@ub`(met 0 a))
164 > =b =-(~&(- -) `@ub`(met 0 a))
171 > =c =-(~&(- -) (xeb b))
167 > =c =-(~&(- -) (xeb b))
173 > [`@ub`a `@ub`(end 0 (dec c) b) `@ub`(bex c)]
170 > [`@ub`a `@ub`(end 0 (dec c) b) `@ub`(bex c)]
174 [0b1010.1010.1010 0b100 0b1.0000]
171 [0b1010.1010.1010 0b100 0b1.0000]
@@ -180,30 +177,27 @@ Examples
181Length-decode
178Length-decode
183−The inverse of `++mat`. Accepts a cell of index `a` and a bitstring `b`
180+The 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`
181and 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
182and 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.
183+offset `a` is advanced.
188−Accepts
185+#### Accepts
191`a` is an atom.
187`a` is an atom.
193`b` is a bitstring as an atom.
189`b` is a bitstring as an atom.
195−Produces
191+#### Produces
198−A cell of two atoms, `p` and `q`.
193+A cell of two atoms.
200−Source
195+#### Source
203− ++ rub :: length-decode
197+ ++ rub
205− |= {a/@ b/@}
199+ |= [a=@ b=@]
206− ^- {p/@ q/@}
200+ ^- [p=@ q=@]
208 =+ [c=0 m=(met 0 b)]
202 =+ [c=0 m=(met 0 b)]
209 |- ?< (gth c m)
203 |- ?< (gth c m)
@@ -217,14 +211,20 @@ Source
217 [(add (add c c) e) (cut 0 [(add d (dec c)) e] b)]
211 [(add (add c c) e) (cut 0 [(add d (dec c)) e] b)]
220−Examples
214+#### Examples
223 > `@ub`(jam 0xaaa)
216 > `@ub`(jam 0xaaa)
224 0b1.0101.0101.0101.0010.0000
217 0b1.0101.0101.0101.0010.0000
225 > (rub 1 0b1.0101.0101.0101.0010.0000)
219 > (rub 1 0b1.0101.0101.0101.0010.0000)
226 [p=20 q=2.730]
220 [p=20 q=2.730]
227 > `@ux`q:(rub 1 0b1.0101.0101.0101.0010.0000)
222 > `@ux`q:(rub 1 0b1.0101.0101.0101.0010.0000)
228+`rub` is only used internally as a helper to `cue`.