on 01ac191 help sign in
287 lines 4.2 kB history raw
1# 1c: molds and mold builders
3### `++bloq`
5Blocksize
7Atom representing a blocksize, by convention expressed as a power of 2.
9Source
10------
12 ++ bloq @ :: blockclass
14Examples
15--------
17 > :: ++met measures how many bloqs long an atom is
18 > (met 3 256)
19 2
20 > :: 256 is 2 bloqs of 2^3
23***
25### `++each`
27Mold of fork between two
29mold generator: produces a dicriminated fork between two types.
31Source
32------
34 ++ each
35 |* {a/$-(* *) b/$-(* *)} :: either a or b
36 $%({$& p/a} {$| p/b}) :: a default
39Examples
40--------
42 > ? *(each cord time)
43 ?({$.y p/@t} {$.n p/@da})
44 [%.y p='']
46***
47### `++gate`
49Function
51A core with one arm, `$`--the empty name--which transforms a sample noun into a product
52noun. If used dryly as a type, the subject must have a sample type of `*`.
55Source
56------
58 ++ gate $-(* *) :: general gate
61Examples
62--------
64See also: `++lift`, `++cork`
66 > ? gate
67 <1.ybc {* <110.jyx 1.ztu $151>}>
68 <1.ybc {* <110.jyx 1.ztu $151>}>
70 > (`gate`|=(a/* [a 'b']) 1)
71 [1 'b']
75***
76### `++list`
78List
80mold generator. `++list` generates a mold of a null-termanated list of a
81homogenous type.
84Source
85------
87 ++ list |* a/$-(* *) :: null-term list
88 $@($~ {i/a t/(list a)}) ::
91Examples
92--------
94See also: `++turn`, `++snag`
96 > *(list)
97 ~
98 > `(list @)`"abc"
99 ~[97 98 99]
100 > (snag 0 "abc")
101 'a'
105***
106### `++lone`
108`++lone` puts face of `p` on something.
110XX unused
112Source
113------
115 ++ lone |*(a/$-(* *) p/a) :: just one thing
117***
118### `++pair`
120Mold of pair of types
122mold generator. Produces a tuple of two of the types passed in.
125Source
126------
128 ++ pair |*({a/$-(* *) b/$-(* *)} {p/a q/b}) :: just a pair
132Examples
133--------
135 > *(pair bean cord)
136 [p=%.y q='']
140***
141### `++pole`
143Faceless list
145A `++list` without the faces `i` and `t`.
147Source
148------
150 ++ pole |* a/$-(* *) :: nameless list
151 $@($~ {a (pole a)}) ::
155Examples
156--------
158 > `(pole char)`"asdf"
159 [~~a [~~s [~~d [~~f ~]]]]
163***
164### `++qual`
166Mold of 4 type tuple
168A `++qual` is a tuple of four of the types passed in.
170Source
171------
173 ++ qual |* {a/$-(* *) b/$-(* *) c/$-(* *) d/$-(* *)} :: just a quadruple
174 {p/a q/b r/c s/d} ::
176Examples
177--------
179 > *(qual date time tape cord)
180 [p=[[a=%.y y=0] m=0 t=[d=0 h=0 m=0 s=0 f=~]] q=~292277024401-.1.1 r="" s='']
184 ***
185### `++trap`
187Core with one arm `$`
189A trap is a core with one arm `++$`.
191Source
192------
194 ++ trap |*(a/_* _|?(*a)) :: makes perfect sense
197Examples
198--------
200 > *trap
201 <1.mws 101.jzo 1.ypj %164>
202 > (*trap)
203 0
204 > (|.(42))
205 42
209***
210### `++tree`
212Tree mold generator
214A `++tree` can be empty, or contain a node of a type and
215left/right sub `++tree` of the same type. Pretty-printed with `{}`.
217Source
218------
220 ++ tree |* a/$-(* *) :: binary tree
221 $@($~ {n/a l/(tree a) r/(tree a)}) ::
224Examples
225--------
227 > `(tree {@ tape})`[[1 "hi"] [[2 "bye"] ~ ~] ~]
228 {[2 "bye"] [1 "hi"]}
232***
233### `++trel`
235Mold of three types
237`++mold` of the tuple of the three types passed in.
239Source
240------
242 ++ trel |* {a/$-(* *) b/$-(* *) c/$-(* *)} :: just a triple
243 {p/a q/b r/c} ::
246Examples
247--------
249 > *(trel @ud @t @s)
250 [p=0 q='' r=--0]
254***
255### `++unit`
257Maybe
259mold generator. A `++unit` is either `~` or `[~ u=a]` where `a` is the
260type that was passed in.
263Source
264------
266 ++ unit |* a/$-(* *) :: maybe
267 $@($~ {$~ u/a}) ::
270Examples
271--------
273See also: `++bind`
275 > ? *(unit time)
276 ?({$~ u/@da} $~)
277 ~
279 > > =a |= a/@
280 ^- (unit @)
281 ?~ a ~
282 [~ a]
283 > (a 2)
284 [~ u=2]
287***