on master help sign in
Update 2q
60f3844rmariani
docs/hoon/library/2q.md+172−103
@@ -6,23 +6,22 @@ navhome: /docs/
6# 2q: molds and mold builders
6# 2q: molds and mold builders
7### `++char`
7### `++char`
8
8
9−Char
9+Character
10
10
11−A single character. odor `@tD` designates a single unicode byte. All
11+A single character. Aura `@tD` designates a single unicode byte. All parsers
12−parsers consume `++tape`s, which are lists of `++char`.
12+consume `tape`s, which are lists of `char`.
13
13
14
14
15−Source
15+#### Source
16−------
17
16
18− ++ char @tD :: UTF-8 byte
17+ ++ char @tD
19
18
20−Examples
19+#### Examples
21−--------
22
20
23 > *char
21 > *char
24 ''
22 ''
23+
25− ~zod/try> (char 97)
24+ > (char 97)
26 'a'
25 'a'
27
26
28
27
@@ -32,123 +31,185 @@ Examples
32
31
33UTF-8 text
32UTF-8 text
34
33
35−One of Hoon's two string types (the other being `++tape`). A cord is an
34+One of Hoon's two string types (the other being `tape`). A cord is an
36−atom of UTF-8 text. `++trip` and `++crip` convert between cord and
35+atom of UTF-8 text.
37−`++tape`.
38
36
39−Source
37+#### Source
40−------
41
38
42− ++ cord @t :: text atom (UTF-8)
39+ ++ cord @t
43
40
44−Examples
41+#### Examples
45−--------
46
42
47−Odor `@t` designates a Unicode atom, little-endian: the first character
48−in the text is the low byte.
49
43
50 > `@ux`'foobar'
44 > `@ux`'foobar'
51 0x7261.626f.6f66
45 0x7261.626f.6f66
52
46
47+ > (cord 97)
48+ 'a'
49+
53 > `@`'urbit'
50 > `@`'urbit'
54 499.984.265.845
51 499.984.265.845
52+
55 > (cord 499.984.265.845)
53 > (cord 499.984.265.845)
56 'urbit'
54 'urbit'
57
55
58
56
57+#### Discussion
58+
59+Aura `@t` designates a Unicode atom, little-endian: the first character
60+in the text is the least-significant byte.
61+
62+[`trip`](../4b) converts from `cord` to `tape`, and [`crip`](../4b) converts
63+from `tape` to `cord`.
64+
65+
59
66
60***
67***
61### `++date`
68### `++date`
62
69
63Point in time
70Point in time
64
71
65−A boolean designating AD or BC, a year atom, a month
72+A boolean designating AD or BC, a year atom, a month atom, and a `tarp`,
66−atom, and a `++tarp`, which is a day atom and a time.
73+which is a day atom and a time.
67−
68−Source
69−------
70
74
71− ++ date {{a/? y/@ud} m/@ud t/tarp} :: parsed date
75+#### Source
72
76
77+ ++ date [[a=? y=@ud] m=@ud t=tarp]
73
78
74−Examples
75−--------
76
79
77−See also: `++year`, `++yore` `++stud`, `++dust`
80+#### Examples
78
81
79 > `date`(yore ~2014.6.6..21.09.15..0a16)
82 > `date`(yore ~2014.6.6..21.09.15..0a16)
80 [[a=%.y y=2.014] m=6 t=[d=6 h=21 m=9 s=15 f=~[0xa16]]]
83 [[a=%.y y=2.014] m=6 t=[d=6 h=21 m=9 s=15 f=~[0xa16]]]
81
84
85+ > now
86+ ~2018.5.25..17.55.15..9ad8
87+
88+
89+
90+#### Discussion
91+
92+See also: [`year`](../3c), [`yore`](../3c) [`stud`](../2q), [`dust`](../2q)
93+
94+***
95+### `++knot`
96+
97+ASCII
98+
99+An atom type that only permits ASCII characters.
100+
101+#### Source
102+
103+++ knot @ta
104+
105+#### Examples
106+
107+ > (knot 105)
108+ ~.i
109+
110+
82
111
83***
112***
84### `++tang`
113### `++tang`
85
114
86− ++ tang (list tank) :: general error
115+Generic print structure
116+
117+A list of `tank`s. It's for printing types and bottom-up printing of stack
118+traces.
87
119
88−Unused XX
120+#### Source
89
121
122+++ tang (list tank)
123+
124+#### Examples
125+
126+ > (~(win re [%palm ["1" "2" "3" "4"] [%leaf "foobar"] [%leaf "bazbud"] [%leaf "zzzzzzqaaa"] ~]) 0 50)
127+ <<"23foobar1bazbud1zzzzzzqaaa4">>
128+
129+ > (~(win re [%palm ["1" "2" "3" "4"] [%leaf "foobar"] [%leaf "bazbud"] [%leaf "zzzzzzqaaa"] ~]) 0 10)
130+ <<"2 foobar" " bazbud" "zzzzzzqaaa">>
131+
132+ > (~(win re [%rose ["1" "2" "3"] [%leaf "foobar"] [%leaf "bazbud"] ~]) 0 20)
133+ <<"2foobar1bazbud3">>
134+
135+ > (~(win re [%rose ["1" "2" "3"] [%leaf "foobar"] [%leaf "bazbud"] ~]) 0 10)
136+ <<"2 foobar" " bazbud" "3">>
90
137
91
138
92***
139***
93### `++tank`
140### `++tank`
94
141
95−Pretty-printing structure.
142+Pretty-printing structure
143+
144+A `tank` is one of three cases: a `%leaf` is simply a string (a printed line);
145+ a `%palm` is list of `tank` delimited by the strings in `p`, with back-steps at
146+new lines; and a `%rose` is a list of `tank` delimited by the strings in `p`
147+without back-steps at new lines.
96
148
97−A `++tank` is one of three cases: a `%leaf`
98−is simply a string; a `%palm` is XX need more information; and a `%rose` is a
99−list of `++tank` delimted by the strings in `p`.
100
149
150+#### Source
101
151
102−Source
152+ ++ tank $% [$leaf p=tape]
103−------
153+ $: $palm
154+ p=[p=tape q=tape r=tape s=tape]
155+ q=(list tank)
156+ ==
157+ $: $rose
158+ p=[p=tape q=tape r=tape]
159+ q=(list tank)
160+ ==
161+ ==
104
162
105− ++ tank $% {$leaf p/tape} :: printing formats
163+#### Examples
106− $: $palm :: backstep list
107− p/{p/tape q/tape r/tape s/tape} ::
108− q/(list tank) ::
109− == ::
110− $: $rose :: flat list
111− p/{p/tape q/tape r/tape} :: mid open close
112− q/(list tank) ::
113− == ::
114− == ::
115
164
116−Examples
117−--------
118
165
119− > >(bex 20) (bex 19)<
120− [%rose p=[p=" " q="[" r="]"] q=~[[%leaf p="1.048.576"] [%leaf p="524.288"]]]
121− > (wash [0 80] >(bex 20) (bex 19)<) :: at 80 cols
166+ > (wash [0 80] >(bex 20) (bex 19)<) :: at 80 cols
122 <<"[1.048.576 524.288]">>
167 <<"[1.048.576 524.288]">>
168+
123− > (wash [0 15] >(bex 20) (bex 19)<) :: at 15 cols (two lines)
169+ > (wash [0 15] >(bex 20) (bex 19)<) :: at 15 cols
124 <<"[ 1.048.576" " 524.288" "]">>
170 <<"[ 1.048.576" " 524.288" "]">>
125
171
126− > [(bex 150) (bex 151)] :: at 80 cols
172+ > [(bex 150) (bex 151)] :: at 80 cols
127 [ 1.427.247.692.705.959.881.058.285.969.449.495.136.382.746.624
173 [ 1.427.247.692.705.959.881.058.285.969.449.495.136.382.746.624
128 2.854.495.385.411.919.762.116.571.938.898.990.272.765.493.248
174 2.854.495.385.411.919.762.116.571.938.898.990.272.765.493.248
129 ]
175 ]
130
176
177+ > (wash [0 40] >(bex 150) (bex 151)<)
178+ <<
179+ "[ \\/1.427.247.692.705.959.881.058.285.\\/"
180+ " 969.449.495.136.382.746.624"
181+ " \\/ \\/"
182+ " \\/2.854.495.385.411.919.762.116.571.\\/"
183+ " 938.898.990.272.765.493.248"
184+ " \\/ \\/"
185+ "]"
186+ >>
131
187
132
188
133−***
134
189
190+***
135### `++tape`
191### `++tape`
136
192
137−List of chars
193+List of characters
138
194
139−One of Hoon's two string types, the other being `++cord`. A tape is a
195+One of Hoon's two string types, the other being `++cord`. A tape is a list of
140−list of chars.
196+`char`.
141
197
142−Source
198+#### Source
143−------
144
199
145− ++ tape (list char) :: like a string
200+ ++ tape (list @tD)
146
201
147−Examples
202+#### Examples
148−--------
149
203
150− > `(list char)`"foobar"
204+ > `tape`"foobar"
151 "foobar"
205 "foobar"
206+
207+ >`(list @t)`"foobar"
208+ <|f o o b a r|>
209+
210+ >`(list @tD)`"foobar"
211+ "foobar"
212+
152 > `(list @)`"foobar"
213 > `(list @)`"foobar"
153 ~[102 111 111 98 97 114]
214 ~[102 111 111 98 97 114]
154
215
@@ -156,26 +217,27 @@ Examples
156***
217***
157### `++tarp`
218### `++tarp`
158
219
159−Day through second
220+Parsed time
221+
222+The time component of a `date`: day, hour, minute, second and a list of `@ux`
223+ for precision.
160
224
161−The remaining part of a `++date`: day, hour, minute, second and a list
225+#### Source
162−of `@ux` for precision.
163
226
164−Source
227+ ++ tarp [d=@ud h=@ud m=@ud s=@ud f=(list @ux)]
165−------
166
228
167− ++ tarp {d/@ud h/@ud m/@ud s/@ud f/(list @ux)} :: parsed time
168
229
230+#### Examples
169
231
170−Examples
171−--------
172
232
233+ > *tarp
234+ [d=0 h=0 m=0 s=0 f=~]
173
235
174− > -<-
236+ > (yell now)
175− ~2014.9.20..00.43.33..b52a
237+ [d=106.751.991.821.625 h=22 m=58 s=10 f=~[0x44ff]]
176− > :: the time is always in your context at -<-
238+
177− > (yell -<-)
239+ > `tarp`(yell ~2014.6.6..21.09.15..0a16)
178− [d=106.751.991.820.278 h=0 m=43 s=39 f=~[0x54d1]]
240+ [d=106.751.991.820.172 h=21 m=9 s=15 f=~[0xa16]]
179
241
180 > (yell ~d20)
242 > (yell ~d20)
181 [d=20 h=0 m=0 s=0 f=~]
243 [d=20 h=0 m=0 s=0 f=~]
@@ -185,42 +247,48 @@ Examples
185***
247***
186### `++term`
248### `++term`
187
249
188−Hoon constants
250+Hoon constant
189
251
190A restricted text atom for Hoon constants. The only characters permitted are
252A restricted text atom for Hoon constants. The only characters permitted are
191−lowercase ASCII, `-`, and `0-9`, the latter two of which can neither be the first or last
253+lowercase ASCII letters, `-`, and `0-9`, the latter two of which cannot be the
192−character. The syntax for `@tas` is the text itself, always preceded by `%`.
254+first character. The syntax for `@tas` is the text itself, always preceded by
193−This means a term is always cubical. The empty `@tas` has a special syntax,
255+`%`. The empty `@tas` has a
194−`$`.
256+special syntax, `$`.
195
257
196
258
197−Source
259+#### Source
198−------
199
260
200− ++ term @tas :: Hoon ASCII subset
261+ ++ term @tas
201
262
202−Examples
263+#### Examples
203−--------
204
264
205 > *term
265 > *term
206 %$
266 %$
207
267
268+ > *%term
269+ %term
270+
208 > %dead-fish9
271 > %dead-fish9
209 %dead-fish9
272 %dead-fish9
273+
210 > -:!>(%dead-fish9)
274 > -:!>(%dead-fish9)
211− [%cube p=271.101.667.197.767.630.546.276 q=[%atom p=%tas]]
275+ #t/$dead-fish9
212
276
213
277
214
278
215***
279***
216### `++wain`
280### `++wain`
217
281
218− ++ wain (list cord) :: text lines (no \n)
282+List of strings
219
283
220−A list of lines. A `++wain` is used instead of a single `++cord` with
284+A list of `cord`s. A `wain` is used instead of a single `cord` with `\n`.
221−`\n`.
222
285
223−See also: `++lore`, `++role`
286+
287+#### Source
288+
289+ ++ wain (list cord)
290+
291+#### Examples
224
292
225 > `wain`/som/del/rok
293 > `wain`/som/del/rok
226 <|som del rok|>
294 <|som del rok|>
@@ -229,28 +297,29 @@ See also: `++lore`, `++role`
229***
297***
230### `++wall`
298### `++wall`
231
299
232−List of lines
300+List of list of characters
233
301
302+A list of `tape`s. `wall` is used instead of a single `tape` with `\n`.
234
303
235−A `++wall` is used instead of a single `++tape` with
304+#### Source
236−`\n`.
237
305
238−Source
306+ ++ wall (list tape)
239−------
240
307
241− ++ wall (list tape) :: text lines (no \n)
308+#### Examples
242
309
243−Examples
244−--------
245−
246−See also: `++wash`
247
310
248 > `wall`(wash [0 20] leaf+<(bex 256)>)
311 > `wall`(wash [0 20] leaf+<(bex 256)>)
249 <<
312 <<
250− "115.792.089.237.316.195.423.570.985.008.687.907.853.269.984.665.640.564.039.457.584.007.913.129.639.936"
313+ "\\/115.792.089.237.\\/"
314+ " 316.195.423.570."
315+ " 985.008.687.907."
316+ " 853.269.984.665."
317+ " 640.564.039.457."
318+ " 584.007.913.129."
319+ " 639.936"
320+ "\\/ \\/"
251 >>
321 >>
252
322
253
323
254
324
255−
256***
325***