on c19bc7a help sign in
379 lines 6.1 kB history raw
1:- :~ navhome/'/docs/'
2 sort/'20'
3 title/'2q: Molds and Mold-Builders'
4 ==
6;>
9# 2q: molds and mold builders
11### `++char`
13Character
15A single character. Aura `@tD` designates a single UTF-8 byte. All parsers
16consume `tape`s, which are lists of `char`.
19#### Source
21```
22 ++ char @tD
23```
25#### Examples
27```
28 > *char
29 ''
31 > `@tD`97
32 'a'
33```
35---
36### `++cord`
38UTF-8 text
40One of Hoon's two string types (the other being `tape`). A cord is an
41atom of UTF-8 text.
43#### Source
45```
46 ++ cord @t
47```
49#### Examples
51```
52 > *cord
53 ''
55 > `@ux`'foobar'
56 0x7261.626f.6f66
58 > `@t`97
59 'a'
61 > `@`'urbit'
62 499.984.265.845
64 > `@t`499.984.265.845
65 'urbit'
66```
68#### Discussion
70Aura `@t` designates a Unicode atom, little-endian: the first character
71in the text is the least-significant byte.
73[`trip`](../4b) converts from `cord` to `tape`, and [`crip`](../4b) converts
74from `tape` to `cord`.
78---
79### `++date`
81Point in time
83A boolean designating AD or BC, a year atom, a month atom, and a `tarp`,
84which is a day atom and a time.
86#### Source
88```
89 ++ date [[a=? y=@ud] m=@ud t=tarp]
90```
92#### Examples
94```
95 > *date
96 [[a=%.y y=0] m=0 t=[d=0 h=0 m=0 s=0 f=~]]
98 > `date`(yore ~2014.6.6..21.09.15..0a16)
99 [[a=%.y y=2.014] m=6 t=[d=6 h=21 m=9 s=15 f=~[0xa16]]]
101 > now
102 ~2018.5.25..17.55.15..9ad8
103```
106#### Discussion
108See also: [`year`](../3c), [`yore`](../3c) [`stud`](../2q), [`dust`](../2q)
110---
111### `++knot`
113ASCII
115An atom type that only permits ASCII characters.
117#### Source
119```
121 ++ knot @ta
122```
124#### Examples
126```
127 > *knot
128 ~.
130 > `@ta`105
131 ~.i
132```
134---
135### `++tang`
137Generic print structure
139A list of `tank`s. It's for printing types and bottom-up printing of stack
140traces.
142#### Source
144```
145 ++ tang (list tank)
146```
148#### Examples
150```
151 > *tang
152 ~
154 > (~(win re [%palm ["1" "2" "3" "4"] [%leaf "foobar"] [%leaf "bazbud"] [%leaf "zzzzzzqaaa"] ~]) 0 50)
155 <<"23foobar1bazbud1zzzzzzqaaa4">>
157 > (~(win re [%palm ["1" "2" "3" "4"] [%leaf "foobar"] [%leaf "bazbud"] [%leaf "zzzzzzqaaa"] ~]) 0 10)
158 <<"2 foobar" " bazbud" "zzzzzzqaaa">>
160 > (~(win re [%rose ["1" "2" "3"] [%leaf "foobar"] [%leaf "bazbud"] ~]) 0 20)
161 <<"2foobar1bazbud3">>
163 > (~(win re [%rose ["1" "2" "3"] [%leaf "foobar"] [%leaf "bazbud"] ~]) 0 10)
164 <<"2 foobar" " bazbud" "3">>
165```
167---
168### `++tank`
170Pretty-printing structure
172A `tank` is one of three cases: a `%leaf` is simply a string (a printed line);
173a `%palm` is list of `tank` delimited by the strings in `p`, with back-steps at
174new lines; and a `%rose` is a list of `tank` delimited by the strings in `p`
175without back-steps at new lines.
178#### Source
180```
181 ++ tank $% [$leaf p=tape]
182 $: $palm
183 p=[p=tape q=tape r=tape s=tape]
184 q=(list tank)
185 ==
186 $: $rose
187 p=[p=tape q=tape r=tape]
188 q=(list tank)
189 ==
190 ==
191```
193#### Examples
196```
197 > *tank
198 [%rose p=[p="" q="" r=""] q=~]
200 > (wash [0 80] >(bex 20) (bex 19)<) :: at 80 cols
201 <<"[1.048.576 524.288]">>
203 > (wash [0 15] >(bex 20) (bex 19)<) :: at 15 cols
204 <<"[ 1.048.576" " 524.288" "]">>
206 > [(bex 150) (bex 151)] :: at 80 cols
207 [ 1.427.247.692.705.959.881.058.285.969.449.495.136.382.746.624
208 2.854.495.385.411.919.762.116.571.938.898.990.272.765.493.248
209 ]
211 > (wash [0 40] >(bex 150) (bex 151)<)
212 <<
213 "[ \\/1.427.247.692.705.959.881.058.285.\\/"
214 " 969.449.495.136.382.746.624"
215 " \\/ \\/"
216 " \\/2.854.495.385.411.919.762.116.571.\\/"
217 " 938.898.990.272.765.493.248"
218 " \\/ \\/"
219 "]"
220 >>
221```
224---
225### `++tape`
227List of characters
229One of Hoon's two string types, the other being `++cord`. A tape is a list of
230`char`.
232#### Source
234```
235 ++ tape (list @tD)
236```
238#### Examples
240```
241 > *tape
242 ""
244 > `tape`"foobar"
245 "foobar"
247 >`(list @t)`"foobar"
248 <|f o o b a r|>
250 >`(list @tD)`"foobar"
251 "foobar"
253 > `(list @)`"foobar"
254 ~[102 111 111 98 97 114]
255```
257---
258### `++tarp`
260Parsed time
262The time component of a `date`: day, hour, minute, second and a list of `@ux`
263for precision.
265#### Source
267```
268 ++ tarp [d=@ud h=@ud m=@ud s=@ud f=(list @ux)]
269```
271#### Examples
273```
274 > *tarp
275 [d=0 h=0 m=0 s=0 f=~]
277 > (yell now)
278 [d=106.751.991.821.625 h=22 m=58 s=10 f=~[0x44ff]]
280 > `tarp`(yell ~2014.6.6..21.09.15..0a16)
281 [d=106.751.991.820.172 h=21 m=9 s=15 f=~[0xa16]]
283 > (yell ~d20)
284 [d=20 h=0 m=0 s=0 f=~]
285```
288---
289### `++term`
291Hoon constant
293A restricted text atom for Hoon constants. The only characters permitted are
294lowercase ASCII letters, `-`, and `0-9`, the latter two of which cannot be the
295first character. The syntax for `@tas` is the text itself, always preceded by
296`%`. The empty `@tas` has a
297special syntax, `$`.
300#### Source
302```
303 ++ term @tas
304```
306#### Examples
308```
309 > *term
310 %$
312 > *%term
313 %term
315 > %dead-fish9
316 %dead-fish9
318 > -:!>(%dead-fish9)
319 #t/$dead-fish9
320```
323---
324### `++wain`
326List of strings
328A list of `cord`s. A `wain` is used instead of a single `cord` with `\n`.
331#### Source
333```
334 ++ wain (list cord)
335```
337#### Examples
339```
340 > *wain
341 <||>
343 > `wain`/som/del/rok
344 <|som del rok|>
345```
347---
348### `++wall`
350List of list of characters
352A list of `tape`s. `wall` is used instead of a single `tape` with `\n`.
354#### Source
356```
357 ++ wall (list tape)
358```
359#### Examples
361```
362 > *wall
363 <<>>
365 > `wall`(wash [0 20] leaf+<(bex 256)>)
366 <<
367 "\\/115.792.089.237.\\/"
368 " 316.195.423.570."
369 " 985.008.687.907."
370 " 853.269.984.665."
371 " 640.564.039.457."
372 " 584.007.913.129."
373 " 639.936"
374 "\\/ \\/"
375 >>
376```
379---