on 4fdc19d help sign in
586 lines 6.7 kB history raw
1+++
2title = "2q: Molds and Mold-Builders"
3weight = 20
4template = "doc.html"
5+++
7## `+$axis`
9Tree address
11A Nock axis inside a noun. After the leading 1, in binary, a `1` signfies
12right and `0` left.
14#### Source
16```hoon
17+$ axis @
18```
20#### Examples
22```
23> =axis `axis`7
24> axis
26> `@ub`axis
270b111
29> =noun [[4 5] [6 14 15]]
31> .*(noun [0 axis])
32[14 15]
33```
35---
37## `+$bean`
39Boolean
41`0`, `&`, or `%.y` are true, and `1`, `|`, and `%.n` are false.
43Note 1 is false and 0 is true. This is sometimes referred to as "loobean".
45#### Source
47```hoon
48+$ bean ?
49```
51#### Examples
53```
54> *bean
55%.y
56```
58```
59> `bean`&
60%.y
61```
63```
64> `bean`|
65%.n
66```
68---
70## `+$flag`
72Boolean
74Same as [$bean](#bean).
76#### Source
78```hoon
79+$ flag ?
80```
82---
84## `+$char`
86Character
88A single `@t` character.
90#### Source
92```hoon
93+$ char @t
94```
96#### Examples
98```
99> *char
100''
101```
103```
104> `char`'a'
105'a'
106```
108---
110## `+$cord`
112UTF-8 text
114One of Hoon's two string types (the other being `tape`). A cord is an
115atom of UTF-8 text.
117#### Source
119```hoon
120+$ cord @t
121```
123#### Examples
125```
126> *cord
127''
129> `@ux`'foobar'
1300x7261.626f.6f66
132> `@t`97
133'a'
135> `@`'urbit'
136499.984.265.845
138> `@t`499.984.265.845
139'urbit'
140```
142#### Discussion
144Aura `@t` designates a Unicode atom, little-endian: the first character
145in the text is the least-significant byte.
147[`trip`](/docs/hoon/reference/stdlib/4b#trip) converts from `cord` to `tape`, and [`crip`](/docs/hoon/reference/stdlib/4b#crip) converts
148from `tape` to `cord`.
150---
152## `+$byts`
154bytes, LSB first
156An atom `dat` with its byte-length specified in `wid`. This is to handle leading zeros that are typically ignored.
158#### Source
160```hoon
161+$ byts [wid=@ud dat=@]
162```
164#### Examples
166```
167> *byts
168[wid=0 dat=0]
169```
171```
172> =a `byts`[4 2]
173> a
174[wid=4 dat=2]
176> `@ux`(rev 3 a)
1770x200.0000
178```
180---
182## `+$date`
184Parsed date
186A boolean designating AD or BC, a year atom, a month atom, and a `tarp`,
187which is a day atom and a time.
189#### Source
191```hoon
192+$ date [[a=? y=@ud] m=@ud t=tarp]
193```
195#### Examples
197```
198> *date
199[[a=%.y y=0] m=0 t=[d=0 h=0 m=0 s=0 f=~]]
201> `date`(yore ~2014.6.6..21.09.15..0a16)
202[[a=%.y y=2.014] m=6 t=[d=6 h=21 m=9 s=15 f=~[0xa16]]]
204> now
205~2018.5.25..17.55.15..9ad8
206```
208#### Discussion
210See also: [`year`](/docs/hoon/reference/stdlib/3c#year), [`yore`](/docs/hoon/reference/stdlib/3c#yore)
212---
214## `+$knot`
216ASCII text
218An atom type that only permits ASCII characters.
220#### Source
222```hoon
223+$ knot @ta
224```
226#### Examples
228```
229> *knot
230~.
232> `@ta`105
233~.i
234```
236---
238## `+$noun`
240Any noun
242#### Source
244```hoon
245+$ noun *
246```
248#### Examples
250```
251> *noun
253```
255```
256> `noun`'foo'
2577.303.014
258```
260```
261> `noun`"foo"
262[102 111 111 0]
263```
265---
267## `+$path`
269Like unix path
271A path is a list of [`$knot`](#knot).
273#### Source
275```hoon
276+$ path (list knot)
277```
279#### Examples
281```
282> *path
284```
286```
287> `path`"foo"
288/f/o/o
289```
291```
292> `path`[~.foo ~.bar ~.baz ~]
293/foo/bar/baz
294```
296---
298## `+$stud`
300Standard name
302#### Source
304```hoon
305+$ stud :: standard name
306 $@ mark=@tas :: auth=urbit
307 $: auth=@tas :: standards authority
308 type=path :: standard label
309 == ::
310```
312---
314## `+$tang`
316Bottom-first error
318A list of [`tank`](#tank)s. It's for printing types and bottom-up printing of stack
319traces.
321#### Source
323```hoon
324+$ tang (list tank)
325```
327#### Examples
329```
330> *tang
332```
334```
335> %- %- slog
336 ^- tang
337 :~ 'foo'
338 leaf+"bar"
339 [%palm ["|" "(" "!" ")"] leaf+"foo" leaf+"bar" leaf+"baz" ~]
340 [%rose [" " "[" "]"] leaf+"foo" leaf+"bar" leaf+"baz" ~]
341 ==
342foo
343bar
344(!foo|bar|baz)
345[foo bar baz]
346 ~
348```
350---
352## `+$tank`
354Formatted print tree
356A `tank` is one of four cases:
358- just a `cord`.
359- `%leaf` is just a `tape`.
360- `%palm` is a list of `tank` delimited by the strings in `p`, with back-steps at new lines.
361- `%rose` is a list of `tank` delimited by the strings in `p` without back-steps at new lines.
363#### Source
365```hoon
366+$ tank
367 $~ leaf/~
368 $@ cord
369 $% [%leaf p=tape]
370 [%palm p=(qual tape tape tape tape) q=(list tank)]
371 [%rose p=(trel tape tape tape) q=(list tank)]
372 ==
373```
375#### Examples
377```
378> *tank
379[%leaf p=""]
380```
382```
383> ~(ram re 'foobar')
384"foobar"
385```
387```
388> ~(ram re leaf+"foo")
389"foo"
390```
392```
393> ~(ram re [%palm ["|" "(" "!" ")"] leaf+"foo" leaf+"bar" leaf+"baz" ~])
394"(!foo|bar|baz)"
395```
397```
398> ~(ram re [%rose [" " "[" "]"] leaf+"foo" leaf+"bar" leaf+"baz" ~])
399"[foo bar baz]"
400```
402---
404## `+$tape`
406List of characters
408One of Hoon's two string types, the other being [`+cord`](#cord). A tape is a list of `@tD`.
410#### Source
412```hoon
413+$ tape (list @tD)
414```
416#### Examples
418```
419> *tape
420""
422> `tape`"foobar"
423"foobar"
425>`(list @t)`"foobar"
426<|f o o b a r|>
428>`(list @tD)`"foobar"
429"foobar"
431> `(list @)`"foobar"
432~[102 111 111 98 97 114]
433```
435---
437## `+$tour`
439UTF-32 clusters
441A `tour` is a list of UTF-32 characters.
443#### Source
445```hoon
446+$ tour (list @c)
447```
449#### Examples
451```
452> *tour
454```
456```
457> `tour`(tuba "foobar")
458~[~-f ~-o ~-o ~-b ~-a ~-r]
459```
461---
463## `+$tarp`
465Parsed time
467The time component of a `date`: day, hour, minute, second and a list of `@ux`
468for precision.
470#### Source
472```hoon
473+$ tarp [d=@ud h=@ud m=@ud s=@ud f=(list @ux)]
474```
476#### Examples
478```
479> *tarp
480[d=0 h=0 m=0 s=0 f=~]
482> (yell now)
483[d=106.751.991.821.625 h=22 m=58 s=10 f=~[0x44ff]]
485> `tarp`(yell ~2014.6.6..21.09.15..0a16)
486[d=106.751.991.820.172 h=21 m=9 s=15 f=~[0xa16]]
488> (yell ~d20)
489[d=20 h=0 m=0 s=0 f=~]
490```
492---
494## `+$term`
496Hoon constant
498A restricted text atom for Hoon constants. The only characters permitted are
499lowercase ASCII letters, `-`, and `0-9`, the latter two of which cannot be the
500first character. The syntax for `@tas` is the text itself, always preceded by
501`%`. The empty `@tas` has a
502special syntax, `$`.
504#### Source
506```hoon
507+$ term @tas
508```
510#### Examples
512```
513> *term
514%$
516> *%term
517%term
519> %dead-fish9
520%dead-fish9
522> -:!>(%dead-fish9)
523#t/%dead-fish9
525> -:!>(`@tas`%dead-fish9)
526#t/@tas
527```
529---
531## `+$wain`
533List of strings
535A list of `cord`s. A `wain` is used instead of a single `cord` with `\n`.
537#### Source
539```hoon
540+$ wain (list cord)
541```
543#### Examples
545```
546> *wain
547<||>
549> `wain`/som/del/rok
550<|som del rok|>
551```
553---
555## `+$wall`
557List of list of characters
559A list of `tape`s. `wall` is used instead of a single `tape` with `\n`.
561#### Source
563```hoon
564+$ wall (list tape)
565```
567#### Examples
569```
570 > *wall
571 <<>>
573 > `wall`(wash [0 20] leaf+<(bex 256)>)
574 <<
575 "\\/115.792.089.237.\\/"
576 " 316.195.423.570."
577 " 985.008.687.907."
578 " 853.269.984.665."
579 " 640.564.039.457."
580 " 584.007.913.129."
581 " 639.936"
582 "\\/ \\/"
583 >>
584```
586---