on 6d45ede help sign in
292 lines 4.3 kB history raw
1---
2navhome: /docs
3---
6# 1c: molds and mold builders
8### `++bloq`
10Blocksize
12Atom representing a blocksize, by convention expressed as a power of 2.
14Source
15------
17 ++ bloq @ :: blockclass
19Examples
20--------
22 > :: ++met measures how many bloqs long an atom is
23 > (met 3 256)
24 2
25 > :: 256 is 2 bloqs of 2^3
28***
30### `++each`
32Mold of fork between two
34mold generator: produces a dicriminated fork between two types.
36Source
37------
39 ++ each
40 |* {a/$-(* *) b/$-(* *)} :: either a or b
41 $%({$& p/a} {$| p/b}) :: a default
44Examples
45--------
47 > ? *(each cord time)
48 ?({$.y p/@t} {$.n p/@da})
49 [%.y p='']
51***
52### `++gate`
54Function
56A core with one arm, `$`--the empty name--which transforms a sample noun into a product
57noun. If used dryly as a type, the subject must have a sample type of `*`.
60Source
61------
63 ++ gate $-(* *) :: general gate
66Examples
67--------
69See also: `++lift`, `++cork`
71 > ? gate
72 <1.ybc {* <110.jyx 1.ztu $151>}>
73 <1.ybc {* <110.jyx 1.ztu $151>}>
75 > (`gate`|=(a/* [a 'b']) 1)
76 [1 'b']
80***
81### `++list`
83List
85mold generator. `++list` generates a mold of a null-termanated list of a
86homogenous type.
89Source
90------
92 ++ list |* a/$-(* *) :: null-term list
93 $@($~ {i/a t/(list a)}) ::
96Examples
97--------
99See also: `++turn`, `++snag`
101 > *(list)
102 ~
103 > `(list @)`"abc"
104 ~[97 98 99]
105 > (snag 0 "abc")
106 'a'
110***
111### `++lone`
113`++lone` puts face of `p` on something.
115XX unused
117Source
118------
120 ++ lone |*(a/$-(* *) p/a) :: just one thing
122***
123### `++pair`
125Mold of pair of types
127mold generator. Produces a tuple of two of the types passed in.
130Source
131------
133 ++ pair |*({a/$-(* *) b/$-(* *)} {p/a q/b}) :: just a pair
137Examples
138--------
140 > *(pair bean cord)
141 [p=%.y q='']
145***
146### `++pole`
148Faceless list
150A `++list` without the faces `i` and `t`.
152Source
153------
155 ++ pole |* a/$-(* *) :: nameless list
156 $@($~ {a (pole a)}) ::
160Examples
161--------
163 > `(pole char)`"asdf"
164 [~~a [~~s [~~d [~~f ~]]]]
168***
169### `++qual`
171Mold of 4 type tuple
173A `++qual` is a tuple of four of the types passed in.
175Source
176------
178 ++ qual |* {a/$-(* *) b/$-(* *) c/$-(* *) d/$-(* *)} :: just a quadruple
179 {p/a q/b r/c s/d} ::
181Examples
182--------
184 > *(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='']
189 ***
190### `++trap`
192Core with one arm `$`
194A trap is a core with one arm `++$`.
196Source
197------
199 ++ trap |*(a/_* _|?(*a)) :: makes perfect sense
202Examples
203--------
205 > *trap
206 <1.mws 101.jzo 1.ypj %164>
207 > (*trap)
208 0
209 > (|.(42))
210 42
214***
215### `++tree`
217Tree mold generator
219A `++tree` can be empty, or contain a node of a type and
220left/right sub `++tree` of the same type. Pretty-printed with `{}`.
222Source
223------
225 ++ tree |* a/$-(* *) :: binary tree
226 $@($~ {n/a l/(tree a) r/(tree a)}) ::
229Examples
230--------
232 > `(tree {@ tape})`[[1 "hi"] [[2 "bye"] ~ ~] ~]
233 {[2 "bye"] [1 "hi"]}
237***
238### `++trel`
240Mold of three types
242`++mold` of the tuple of the three types passed in.
244Source
245------
247 ++ trel |* {a/$-(* *) b/$-(* *) c/$-(* *)} :: just a triple
248 {p/a q/b r/c} ::
251Examples
252--------
254 > *(trel @ud @t @s)
255 [p=0 q='' r=--0]
259***
260### `++unit`
262Maybe
264mold generator. A `++unit` is either `~` or `[~ u=a]` where `a` is the
265type that was passed in.
268Source
269------
271 ++ unit |* a/$-(* *) :: maybe
272 $@($~ {$~ u/a}) ::
275Examples
276--------
278See also: `++bind`
280 > ? *(unit time)
281 ?({$~ u/@da} $~)
282 ~
284 > > =a |= a/@
285 ^- (unit @)
286 ?~ a ~
287 [~ a]
288 > (a 2)
289 [~ u=2]
292***