@@ -8,29 +8,26 @@ navhome: /docs/
88
99Unpack atom to noun
1010
11−Produces a noun unpacked from atom `a`. The inverse of jam.
11+Produces a noun unpacked from atom `a`. The inverse of `jam`.
1212
13−Accepts
14−-------
13+#### Accepts
1514
1615`a` is an atom.
1716
18−Produces
19−--------
17+#### Produces
2018
21−A `++noun`.
19+A noun.
2220
23−Source
24−------
21+#### Source
2522
26− ++ cue :: unpack
23+ ++ cue
2724 ~/ %cue
28− |= a/@
25+ |= a=@
2926 ^- *
3027 =+ b=0
3128 =+ m=`(map @ *)`~
3229 =< q
33− |- ^- {p/@ q/* r/(map @ *)}
30+ |- ^- [p=@ q=* r=(map @ *)]
3431 ?: =(0 (cut 0 [b 1] a))
3532 =+ c=(rub +(b) a)
3633 [+(p.c) q.c (~(put by m) b q.c)]
@@ -42,18 +39,18 @@ Source
4239 [(add 2 (add p.u p.v)) w (~(put by r.v) b w)]
4340 =+ d=(rub c a)
4441 [(add 2 p.d) (need (~(get by m) q.d)) m]
45− ::
4642
47−
48−Examples
49−--------
43+#### Examples
5044
5145 > (cue 12)
5246 1
47+
5348 > (cue 817)
5449 [1 1]
50+
5551 > (cue 4.657)
5652 [1 2]
53+
5754 > (cue 39.689)
5855 [0 19]
5956
@@ -63,29 +60,26 @@ Examples
6360
6461Pack noun to atom
6562
66−Produces an atom packed from noun `a`. The inverse of cue.
63+Produces an atom packed from noun `a`. The inverse of `cue`.
6764
68−Accepts
69−-------
65+#### Accepts
7066
7167`a` is a noun.
7268
73−Produces
74−--------
69+#### Produces
7570
7671An atom.
7772
78−Source
79−------
73+#### Source
8074
81− ++ jam :: pack
75+ ++ jam
8276 ~/ %jam
83− |= a/*
77+ |= a=*
8478 ^- @
8579 =+ b=0
8680 =+ m=`(map * @)`~
8781 =< q
88− |- ^- {p/@ q/@ r/(map * @)}
82+ |- ^- [p=@ q=@ r=(map * @)]
8983 =+ c=(~(get by m) a)
9084 ?~ c
9185 => .(m (~(put by m) a b))
@@ -101,18 +95,19 @@ Source
10195 [(add 1 p.d) (lsh 0 1 q.d) m]
10296 =+ d=(mat u.c)
10397 [(add 2 p.d) (mix 3 (lsh 0 2 q.d)) m]
104− ::
10598
10699
107−Examples
108−--------
100+#### Examples
109101
110102 > (jam 1)
111103 12
104+
112105 > (jam [1 1])
113106 817
107+
114108 > (jam [1 2])
115109 4.657
110+
116111 > (jam [~ u=19])
117112 39.689
118113
@@ -127,49 +122,50 @@ Produces a cell whose tail `q` is atom `a` with a bit representation of
127122its length prepended to it (as the least significant bits). The head `p`
128123is the length of `q` in bits.
129124
130−Accepts
131−-------
125+#### Accepts
132126
133127`a` is an atom.
134128
135−Produces
136−--------
129+#### Produces
137130
138−A cell of two atoms, `p` and `q`.
131+A cell of two atom.
139132
140−Source
141−------
133+#### Source
142134
143− ++ mat :: length-encode
135+ ++ mat
144136 ~/ %mat
145− |= a/@
146− ^- {p/@ q/@}
137+ |= a=@
138+ ^- [p=@ q=@]
147139 ?: =(0 a)
148140 [1 1]
149141 =+ b=(met 0 a)
150142 =+ c=(met 0 b)
151143 :- (add (add c c) b)
152144 (cat 0 (bex c) (mix (end 0 (dec c) b) (lsh 0 (dec c) a)))
153− ::
154−
155145
156−Examples
157−--------
146+#### Examples
158147
159148 > (mat 0xaaa)
160149 [p=20 q=699.024]
150+
161151 > (met 0 q:(mat 0xaaa))
162152 20
153+
163154 > `@ub`q:(mat 0xaaa)
164155 0b1010.1010.1010.1001.0000
156+
165157 > =a =-(~&(- -) `@ub`0xaaa)
166158 0b1010.1010.1010
159+
167160 > =b =-(~&(- -) `@ub`(xeb a))
168161 0b1100
162+
169163 > =b =-(~&(- -) `@ub`(met 0 a))
170164 0b1100
165+
171166 > =c =-(~&(- -) (xeb b))
172167 4
168+
173169 > [`@ub`a `@ub`(end 0 (dec c) b) `@ub`(bex c)]
174170 [0b1010.1010.1010 0b100 0b1.0000]
175171
@@ -183,27 +179,24 @@ Length-decode
183179The inverse of `++mat`. Accepts a cell of index `a` and a bitstring `b`
184180and produces the cell whose tail `q` is the decoded atom at index `a`
185181and 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.
187183
188−Accepts
189−-------
184+#### Accepts
190185
191186`a` is an atom.
192187
193188`b` is a bitstring as an atom.
194189
195−Produces
196−--------
190+#### Produces
197191
198−A cell of two atoms, `p` and `q`.
192+A cell of two atoms.
199193
200−Source
201−------
194+#### Source
202195
203− ++ rub :: length-decode
196+ ++ rub
204197 ~/ %rub
205− |= {a/@ b/@}
206− ^- {p/@ q/@}
198+ |= [a=@ b=@]
199+ ^- [p=@ q=@]
207200 =+ ^= c
208201 =+ [c=0 m=(met 0 b)]
209202 |- ?< (gth c m)
@@ -217,14 +210,20 @@ Source
217210 [(add (add c c) e) (cut 0 [(add d (dec c)) e] b)]
218211
219212
220−Examples
221−--------
213+#### Examples
222214
223215 > `@ub`(jam 0xaaa)
224216 0b1.0101.0101.0101.0010.0000
217+
225218 > (rub 1 0b1.0101.0101.0101.0010.0000)
226219 [p=20 q=2.730]
220+
227221 > `@ux`q:(rub 1 0b1.0101.0101.0101.0010.0000)
228222 0xaaa
229223
224+
225+#### Discussion
226+
227+Only used internally as a helper cue.
228+
230229***