on 140ac0e help sign in
285 lines 4.2 kB history raw
1# 1c: molds and mold builders
2### `++bloq`
4Blocksize
6Atom representing a blocksize, by convention expressed as a power of 2.
8Source
9------
11 ++ bloq @ :: blockclass
13Examples
14--------
16 > :: ++met measures how many bloqs long an atom is
17 > (met 3 256)
18 2
19 > :: 256 is 2 bloqs of 2^3
22***
23### `++each`
25Mold of fork between two
27mold generator: produces a dicriminated fork between two types.
29Source
30------
32 ++ each
33 |* {a/$-(* *) b/$-(* *)} :: either a or b
34 $%({$& p/a} {$| p/b}) :: a default
37Examples
38--------
40 > ? *(each cord time)
41 ?({$.y p/@t} {$.n p/@da})
42 [%.y p='']
44***
45### `++gate`
47Function
49A core with one arm, `$`--the empty name--which transforms a sample noun into a product
50noun. If used dryly as a type, the subject must have a sample type of `*`.
53Source
54------
56 ++ gate $-(* *) :: general gate
59Examples
60--------
62See also: `++lift`, `++cork`
64 > ? gate
65 <1.ybc {* <110.jyx 1.ztu $151>}>
66 <1.ybc {* <110.jyx 1.ztu $151>}>
68 > (`gate`|=(a/* [a 'b']) 1)
69 [1 'b']
73***
74### `++list`
76List
78mold generator. `++list` generates a mold of a null-termanated list of a
79homogenous type.
82Source
83------
85 ++ list |* a/$-(* *) :: null-term list
86 $@($~ {i/a t/(list a)}) ::
89Examples
90--------
92See also: `++turn`, `++snag`
94 > *(list)
95 ~
96 > `(list @)`"abc"
97 ~[97 98 99]
98 > (snag 0 "abc")
99 'a'
103***
104### `++lone`
106`++lone` puts face of `p` on something.
108XX unused
110Source
111------
113 ++ lone |*(a/$-(* *) p/a) :: just one thing
115***
116### `++pair`
118Mold of pair of types
120mold generator. Produces a tuple of two of the types passed in.
123Source
124------
126 ++ pair |*({a/$-(* *) b/$-(* *)} {p/a q/b}) :: just a pair
130Examples
131--------
133 > *(pair bean cord)
134 [p=%.y q='']
138***
139### `++pole`
141Faceless list
143A `++list` without the faces `i` and `t`.
145Source
146------
148 ++ pole |* a/$-(* *) :: nameless list
149 $@($~ {a (pole a)}) ::
153Examples
154--------
156 > `(pole char)`"asdf"
157 [~~a [~~s [~~d [~~f ~]]]]
161***
162### `++qual`
164Mold of 4 type tuple
166A `++qual` is a tuple of four of the types passed in.
168Source
169------
171 ++ qual |* {a/$-(* *) b/$-(* *) c/$-(* *) d/$-(* *)} :: just a quadruple
172 {p/a q/b r/c s/d} ::
174Examples
175--------
177 > *(qual date time tape cord)
178 [p=[[a=%.y y=0] m=0 t=[d=0 h=0 m=0 s=0 f=~]] q=~292277024401-.1.1 r="" s='']
182 ***
183### `++trap`
185Core with one arm `$`
187A trap is a core with one arm `++$`.
189Source
190------
192 ++ trap |*(a/_* _|?(*a)) :: makes perfect sense
195Examples
196--------
198 > *trap
199 <1.mws 101.jzo 1.ypj %164>
200 > (*trap)
201 0
202 > (|.(42))
203 42
207***
208### `++tree`
210Tree mold generator
212A `++tree` can be empty, or contain a node of a type and
213left/right sub `++tree` of the same type. Pretty-printed with `{}`.
215Source
216------
218 ++ tree |* a/$-(* *) :: binary tree
219 $@($~ {n/a l/(tree a) r/(tree a)}) ::
222Examples
223--------
225 > `(tree {@ tape})`[[1 "hi"] [[2 "bye"] ~ ~] ~]
226 {[2 "bye"] [1 "hi"]}
230***
231### `++trel`
233Mold of three types
235`++mold` of the tuple of the three types passed in.
237Source
238------
240 ++ trel |* {a/$-(* *) b/$-(* *) c/$-(* *)} :: just a triple
241 {p/a q/b r/c} ::
244Examples
245--------
247 > *(trel @ud @t @s)
248 [p=0 q='' r=--0]
252***
253### `++unit`
255Maybe
257mold generator. A `++unit` is either `~` or `[~ u=a]` where `a` is the
258type that was passed in.
261Source
262------
264 ++ unit |* a/$-(* *) :: maybe
265 $@($~ {$~ u/a}) ::
268Examples
269--------
271See also: `++bind`
273 > ? *(unit time)
274 ?({$~ u/@da} $~)
275 ~
277 > > =a |= a/@
278 ^- (unit @)
279 ?~ a ~
280 [~ a]
281 > (a 2)
282 [~ u=2]
285***