@@ -9,137 +9,205 @@ navhome: /docs/
12−Atom representing a blocksize, by convention expressed as a power of 2.
12+Atom representing block size. A block of size `a` has a bitwidth of `2^a`.
17− ++ bloq @ :: blockclass
16+ ++ bloq @
19−Examples
18+#### Examples
22− > :: ++met measures how many bloqs long an atom is
20+ :: ++met measures how many a-bloqs long an atom is.
23− > (met 3 256)
22+ > (met 3 256)
25− > :: 256 is 2 bloqs of 2^3
40+ > (met 5 9.999.999.999)
48+You can think of `bloq` as a numeral system that can represent values of
49+`a^2^2`, where `a` is the block size. That's because a block of size
50+`a` contains `a^2` bits, and a binary number that is `b` bits wide can represent
53+A `bloq` of 0 has a bitwidth of 1. (2^0 bits; can represent 2 values.)
55+A `bloq` of 1 has a bitwidth of 2. (2^1 bits; can represent 4 values.)
57+A `bloq` of 2 has a bitwidth of 4. (2^2 bits; can represent 16 values.)
59+A `bloq` of 3 has a bitwidth of 8. (2^3 bits; can represent 256 values.)
63+See the [bit arithmetic](../2c) section for operations that use `bloq`s.
30### `++each`
67### `++each`
32−Mold of fork between two
69+Mold of fork between two types
34−mold generator: produces a discriminated fork between two types.
71+A mold generator. Produces a discriminated fork between two types, defaulting to
40− |* {a/$-(* *) b/$-(* *)} :: either a or b
77+ |*([a=mold b=mold] $%([$| p=b] [$& p=a]))
41− $%({$& p/a} {$| p/b}) :: a default
44−Examples
80+#### Examples
47 > ? *(each cord time)
82 > ? *(each cord time)
48 ?({$.y p/@t} {$.n p/@da})
83 ?({$.y p/@t} {$.n p/@da})
49 [%.y p='']
84 [%.y p='']
87+ ?({$.y p/*} {$.n p/""})
52### `++gate`
91### `++gate`
56−A core with one arm, `$`--the empty name--which transforms a sample noun into a product
95+A core with one arm, `$`--the empty name--which transforms a sample noun into a
57−noun. If used dryly as a type, the subject must have a sample type of `*`.
96+product noun. If used dryly as a type, the subject must have a sample type of
63− ++ gate $-(* *) :: general gate
102+ ++ gate
66−Examples
106+#### Examples
69−See also: `++lift`, `++cork`
72− <1.ybc {* <110.jyx 1.ztu $151>}>
109+ <1.rdl {* <31.ohr 1.jmk $143>}>
73− <1.ybc {* <110.jyx 1.ztu $151>}>
110+ <1.rdl {* <31.ohr 1.jmk $143>}>
112+ > (`gate`|=(a=* [a 'b']) 1)
115+ > (`gate`|=(a=@ [a 'b']) 1)
75− > (`gate`|=(a/* [a 'b']) 1)
119+#### Discussion
121+A `gate` is analogous to a function in other programming languages. We created
122+this new jargon because other constructs in Urbit are "functions" in the
123+mathematical sense. Any `gate` normalizes to an iron `gate`.
125+See also: [`++lift`](../2a), [`++cork`](../2n)
81### `++list`
128### `++list`
85−mold generator. `++list` generates a mold of a null-termanated list of a
132+A mold generator. Generates a mold of a null-terminated list of a
86homogenous type.
133homogenous type.
92− ++ list |* a/$-(* *) :: null-term list
138+ ++ list
93− $@($~ {i/a t/(list a)}) ::
139+ |*(a=mold $@($~ (lest a)))
96−Examples
142+#### Examples
99−See also: `++turn`, `++snag`
101 > *(list)
144 > *(list)
103 > `(list @)`"abc"
147 > `(list @)`"abc"
104 ~[97 98 99]
148 ~[97 98 99]
105 > (snag 0 "abc")
150 > (snag 0 "abc")
153+ > `(list @)`[1 2 'j' ~]
158+See also: [`++turn`](../2b), [`++snag`](../2b)
111### `++lone`
161### `++lone`
113−`++lone` puts face of `p` on something.
163+Face on mold
165+A mold generator. Puts face of `p` on the passed-in mold.
115−XX unused
172+#### Examples
120− ++ lone |*(a/$-(* *) p/a) :: just one thing
175+ > ? *cord
123### `++pair`
190### `++pair`
125Mold of pair of types
192Mold of pair of types
127−mold generator. Produces a tuple of two of the types passed in.
194+A mold generator. Produces a tuple of two of the types passed in.
130−Source
197+#### Source
133− ++ pair |*({a/$-(* *) b/$-(* *)} {p/a q/b}) :: just a pair
199+ ++ pair
200+ |*([a=mold b=mold] [p=a q=b])
137−Examples
204+#### Examples
140− > *(pair bean cord)
206+ > *(pair ? cord)
141 [p=%.y q='']
207 [p=%.y q='']
@@ -147,105 +215,93 @@ Examples
148Faceless list
216Faceless list
150−A `++list` without the faces `i` and `t`.
218+A mold generator. A `list` without the faces `i` and `t`.
153−------
223+ |*(a=mold $@($~ [a (pole a)]))
155− ++ pole |* a/$-(* *) :: nameless list
156− $@($~ {a (pole a)}) ::
160−Examples
229+ > =/(a "asdf" ?>(?=(^ a) `(lest @tD)`a))
161−--------
230+ [i='a' t=[i='s' t=[i='d' t=[i='f' t=~]]]]
163 > `(pole char)`"asdf"
232 > `(pole char)`"asdf"
164− [~~a [~~s [~~d [~~f ~]]]]
233+ ['a' ['s' ['d' ['f' ~]]]]
169### `++qual`
238### `++qual`
171−Mold of 4 type tuple
240+Mold of 4-type tuple
173−A `++qual` is a tuple of four of the types passed in.
242+A mold generator. Produces a tuple of four of the types passed in.
175−Source
244+#### Source
178− ++ qual |* {a/$-(* *) b/$-(* *) c/$-(* *) d/$-(* *)} :: just a quadruple
246+ ++ qual
247+ |* [a=mold b=mold c=mold d=mold]
179− {p/a q/b r/c s/d} ::
248+ [p=a q=b r=c s=d]
181−Examples
250+#### Examples
184 > *(qual date time tape cord)
252 > *(qual date time tape cord)
185 [p=[[a=%.y y=0] m=0 t=[d=0 h=0 m=0 s=0 f=~]] q=~292277024401-.1.1 r="" s='']
253 [p=[[a=%.y y=0] m=0 t=[d=0 h=0 m=0 s=0 f=~]] q=~292277024401-.1.1 r="" s='']
187−
255+ > *(qual (list @) @u @ud @ux)
188−
256+ [p=~ q=0 r=0 s=0x0]
192−For use with `=^` `:sip`.
194−Mold generator. Produces a tuple of `a` and the mold of `b`.
199− ++ quid |*({a/mold b/*} {a _b}) :: mixed for sip
210### `++quip`
260### `++quip`
212−For use with `=^` `:sip`.
262+Mold of pair of `list` and type
214−Mold generator. Produces a tuple of a list of `a` and the mold of `b`.
264+A mold generator. Produces a tuple of a `list` of `a` and the mold of `b`.
216−Source
266+#### Source
219− ++ quip |*({a/mold b/*} {(list a) _b}) :: list-mixed for sip
269+ |*([a=mold b=mold] [(list a) b])
221−Examples
271+#### Examples
224− > *(quip @ 'hi')
273+ > *(quip @ _'hi')
276+ > `(quip @ @ux)`[[1 2 3 4 ~] 0x10]
281+A common pattern in Hoon code is to return a `list` of changes, along with a
282+new state. You'll often see `quip` used in Gall apps.
230### `++trap`
285### `++trap`
232Core with one arm `$`
287Core with one arm `$`
234−A trap is a core with one arm `++$`.
289+A trap is a core with one arm `$`.
236−Source
291+#### Source
239− ++ trap |*(a/_* _|?(*a)) :: makes perfect sense
293+ ++ trap
242−Examples
297+#### Examples
246− <1.mws 101.jzo 1.ypj %164>
247 > (*trap)
299 > (*trap)
300+ <1?dxy 1.oeg {a/<1|rbb {* <31.ohr 1.jmk $143>}> <31.ohr 1.jmk $143>}>
249 > (|.(42))
305 > (|.(42))
@@ -256,20 +312,18 @@ Examples
257Tree mold generator
313Tree mold generator
259−A `++tree` can be empty, or contain a node of a type and
315+A mold generator. A `tree` can be empty, or contain a node of a type and
260−left/right sub `++tree` of the same type. Pretty-printed with `{}`.
316+left/right sub `tree` of the same type. Pretty-printed with `{}`.
262−Source
318+#### Source
265− ++ tree |* a/$-(* *) :: binary tree
320+ ++ tree
266− $@($~ {n/a l/(tree a) r/(tree a)}) ::
321+ |*(a=mold $@($~ [n=a l=(tree a) r=(tree a)]))
269−Examples
324+#### Examples
272− > `(tree {@ tape})`[[1 "hi"] [[2 "bye"] ~ ~] ~]
326+ > `(tree [@ tape])`[[1 "hi"] [[2 "bye"] ~ ~] ~]
273 {[2 "bye"] [1 "hi"]}
327 {[2 "bye"] [1 "hi"]}
@@ -279,21 +333,21 @@ Examples
280Mold of three types
334Mold of three types
282−`++mold` of the tuple of the three types passed in.
336+A mold generator. A mold of the tuple of the three types passed in.
284−Source
338+#### Source
287− ++ trel |* {a/$-(* *) b/$-(* *) c/$-(* *)} :: just a triple
340+ ++ trel
288− {p/a q/b r/c} ::
341+ |*([a=mold b=mold c=mold] [p=a q=b r=c])
291−Examples
344+#### Examples
294 > *(trel @ud @t @s)
346 > *(trel @ud @t @s)
295 [p=0 q='' r=--0]
347 [p=0 q='' r=--0]
349+ > *(trel cord bloq tape)
@@ -301,32 +355,33 @@ Examples
304−mold generator. A `++unit` is either `~` or `[~ u=a]` where `a` is the
358+A mold generator. A `unit` is either `~` or `[~ u=a]`, where `a` is the
305type that was passed in.
359type that was passed in.
308−Source
362+#### Source
311− ++ unit |* a/$-(* *) :: maybe
365+ |*(a=mold $@($~ [$~ u=a]))
315−Examples
367+#### Examples
320 > ? *(unit time)
370 > ? *(unit time)
321− ?({$~ u/@da} $~)
371+ ?({$~ u/@da} $~)
324− > > =a |= a/@
374+ > =a |= a=@
325− ^- (unit @)
375+ ^- (unit @)
383+Using a `unit` allows you to specify something that may not be there.
385+See also: [`++bind`](../2b)