on b93c19b help sign in
374 lines 6.1 kB history raw
1+++
2title = "2q: Molds and Mold-Builders"
3weight = 20
4template = "doc.html"
5+++
6### `++char`
8Character
10A single character. Aura `@tD` designates a single UTF-8 byte. All parsers
11consume `tape`s, which are lists of `char`.
14#### Source
16```
17 ++ char @tD
18```
20#### Examples
22```
23 > *char
24 ''
26 > `@tD`97
27 'a'
28```
30---
31### `++cord`
33UTF-8 text
35One of Hoon's two string types (the other being `tape`). A cord is an
36atom of UTF-8 text.
38#### Source
40```
41 ++ cord @t
42```
44#### Examples
46```
47 > *cord
48 ''
50 > `@ux`'foobar'
51 0x7261.626f.6f66
53 > `@t`97
54 'a'
56 > `@`'urbit'
57 499.984.265.845
59 > `@t`499.984.265.845
60 'urbit'
61```
63#### Discussion
65Aura `@t` designates a Unicode atom, little-endian: the first character
66in the text is the least-significant byte.
68[`trip`](@/docs/reference/library/4b.md) converts from `cord` to `tape`, and [`crip`](@/docs/reference/library/4b.md) converts
69from `tape` to `cord`.
73---
74### `++date`
76Point in time
78A boolean designating AD or BC, a year atom, a month atom, and a `tarp`,
79which is a day atom and a time.
81#### Source
83```
84 ++ date [[a=? y=@ud] m=@ud t=tarp]
85```
87#### Examples
89```
90 > *date
91 [[a=%.y y=0] m=0 t=[d=0 h=0 m=0 s=0 f=~]]
93 > `date`(yore ~2014.6.6..21.09.15..0a16)
94 [[a=%.y y=2.014] m=6 t=[d=6 h=21 m=9 s=15 f=~[0xa16]]]
96 > now
97 ~2018.5.25..17.55.15..9ad8
98```
101#### Discussion
103See also: [`year`](@/docs/reference/library/3c.md), [`yore`](@/docs/reference/library/3c.md)
105---
106### `++knot`
108ASCII
110An atom type that only permits ASCII characters.
112#### Source
114```
116 ++ knot @ta
117```
119#### Examples
121```
122 > *knot
123 ~.
125 > `@ta`105
126 ~.i
127```
129---
130### `++tang`
132Generic print structure
134A list of `tank`s. It's for printing types and bottom-up printing of stack
135traces.
137#### Source
139```
140 ++ tang (list tank)
141```
143#### Examples
145```
146 > *tang
147 ~
149 > (~(win re [%palm ["1" "2" "3" "4"] [%leaf "foobar"] [%leaf "bazbud"] [%leaf "zzzzzzqaaa"] ~]) 0 50)
150 <<"23foobar1bazbud1zzzzzzqaaa4">>
152 > (~(win re [%palm ["1" "2" "3" "4"] [%leaf "foobar"] [%leaf "bazbud"] [%leaf "zzzzzzqaaa"] ~]) 0 10)
153 <<"2 foobar" " bazbud" "zzzzzzqaaa">>
155 > (~(win re [%rose ["1" "2" "3"] [%leaf "foobar"] [%leaf "bazbud"] ~]) 0 20)
156 <<"2foobar1bazbud3">>
158 > (~(win re [%rose ["1" "2" "3"] [%leaf "foobar"] [%leaf "bazbud"] ~]) 0 10)
159 <<"2 foobar" " bazbud" "3">>
160```
162---
163### `++tank`
165Pretty-printing structure
167A `tank` is one of three cases: a `%leaf` is simply a string (a printed line);
168a `%palm` is list of `tank` delimited by the strings in `p`, with back-steps at
169new lines; and a `%rose` is a list of `tank` delimited by the strings in `p`
170without back-steps at new lines.
173#### Source
175```
176 ++ tank $% [$leaf p=tape]
177 $: $palm
178 p=[p=tape q=tape r=tape s=tape]
179 q=(list tank)
180 ==
181 $: $rose
182 p=[p=tape q=tape r=tape]
183 q=(list tank)
184 ==
185 ==
186```
188#### Examples
191```
192 > *tank
193 [%rose p=[p="" q="" r=""] q=~]
195 > (wash [0 80] >(bex 20) (bex 19)<) :: at 80 cols
196 <<"[1.048.576 524.288]">>
198 > (wash [0 15] >(bex 20) (bex 19)<) :: at 15 cols
199 <<"[ 1.048.576" " 524.288" "]">>
201 > [(bex 150) (bex 151)] :: at 80 cols
202 [ 1.427.247.692.705.959.881.058.285.969.449.495.136.382.746.624
203 2.854.495.385.411.919.762.116.571.938.898.990.272.765.493.248
204 ]
206 > (wash [0 40] >(bex 150) (bex 151)<)
207 <<
208 "[ \\/1.427.247.692.705.959.881.058.285.\\/"
209 " 969.449.495.136.382.746.624"
210 " \\/ \\/"
211 " \\/2.854.495.385.411.919.762.116.571.\\/"
212 " 938.898.990.272.765.493.248"
213 " \\/ \\/"
214 "]"
215 >>
216```
219---
220### `++tape`
222List of characters
224One of Hoon's two string types, the other being `++cord`. A tape is a list of
225`char`.
227#### Source
229```
230 ++ tape (list @tD)
231```
233#### Examples
235```
236 > *tape
237 ""
239 > `tape`"foobar"
240 "foobar"
242 >`(list @t)`"foobar"
243 <|f o o b a r|>
245 >`(list @tD)`"foobar"
246 "foobar"
248 > `(list @)`"foobar"
249 ~[102 111 111 98 97 114]
250```
252---
253### `++tarp`
255Parsed time
257The time component of a `date`: day, hour, minute, second and a list of `@ux`
258for precision.
260#### Source
262```
263 ++ tarp [d=@ud h=@ud m=@ud s=@ud f=(list @ux)]
264```
266#### Examples
268```
269 > *tarp
270 [d=0 h=0 m=0 s=0 f=~]
272 > (yell now)
273 [d=106.751.991.821.625 h=22 m=58 s=10 f=~[0x44ff]]
275 > `tarp`(yell ~2014.6.6..21.09.15..0a16)
276 [d=106.751.991.820.172 h=21 m=9 s=15 f=~[0xa16]]
278 > (yell ~d20)
279 [d=20 h=0 m=0 s=0 f=~]
280```
283---
284### `++term`
286Hoon constant
288A restricted text atom for Hoon constants. The only characters permitted are
289lowercase ASCII letters, `-`, and `0-9`, the latter two of which cannot be the
290first character. The syntax for `@tas` is the text itself, always preceded by
291`%`. The empty `@tas` has a
292special syntax, `$`.
295#### Source
297```
298 ++ term @tas
299```
301#### Examples
303```
304 > *term
305 %$
307 > *%term
308 %term
310 > %dead-fish9
311 %dead-fish9
313 > -:!>(%dead-fish9)
314 #t/$dead-fish9
315```
318---
319### `++wain`
321List of strings
323A list of `cord`s. A `wain` is used instead of a single `cord` with `\n`.
326#### Source
328```
329 ++ wain (list cord)
330```
332#### Examples
334```
335 > *wain
336 <||>
338 > `wain`/som/del/rok
339 <|som del rok|>
340```
342---
343### `++wall`
345List of list of characters
347A list of `tape`s. `wall` is used instead of a single `tape` with `\n`.
349#### Source
351```
352 ++ wall (list tape)
353```
354#### Examples
356```
357 > *wall
358 <<>>
360 > `wall`(wash [0 20] leaf+<(bex 256)>)
361 <<
362 "\\/115.792.089.237.\\/"
363 " 316.195.423.570."
364 " 985.008.687.907."
365 " 853.269.984.665."
366 " 640.564.039.457."
367 " 584.007.913.129."
368 " 639.936"
369 "\\/ \\/"
370 >>
371```
374---