# 1c: molds and mold builders ### `++bloq` Blocksize Atom representing a blocksize, by convention expressed as a power of 2. Source ------ ++ bloq @ :: blockclass Examples -------- > :: ++met measures how many bloqs long an atom is > (met 3 256) 2 > :: 256 is 2 bloqs of 2^3 *** ### `++each` Mold of fork between two mold generator: produces a dicriminated fork between two types. Source ------ ++ each |* {a/$-(* *) b/$-(* *)} :: either a or b $%({$& p/a} {$| p/b}) :: a default Examples -------- > ? *(each cord time) ?({$.y p/@t} {$.n p/@da}) [%.y p=''] *** ### `++gate` Function A core with one arm, `$`--the empty name--which transforms a sample noun into a product noun. If used dryly as a type, the subject must have a sample type of `*`. Source ------ ++ gate $-(* *) :: general gate Examples -------- See also: `++lift`, `++cork` > ? gate <1.ybc {* <110.jyx 1.ztu $151>}> <1.ybc {* <110.jyx 1.ztu $151>}> > (`gate`|=(a/* [a 'b']) 1) [1 'b'] *** ### `++list` List mold generator. `++list` generates a mold of a null-termanated list of a homogenous type. Source ------ ++ list |* a/$-(* *) :: null-term list $@($~ {i/a t/(list a)}) :: Examples -------- See also: `++turn`, `++snag` > *(list) ~ > `(list @)`"abc" ~[97 98 99] > (snag 0 "abc") 'a' *** ### `++lone` `++lone` puts face of `p` on something. XX unused Source ------ ++ lone |*(a/$-(* *) p/a) :: just one thing *** ### `++pair` Mold of pair of types mold generator. Produces a tuple of two of the types passed in. Source ------ ++ pair |*({a/$-(* *) b/$-(* *)} {p/a q/b}) :: just a pair Examples -------- > *(pair bean cord) [p=%.y q=''] *** ### `++pole` Faceless list A `++list` without the faces `i` and `t`. Source ------ ++ pole |* a/$-(* *) :: nameless list $@($~ {a (pole a)}) :: Examples -------- > `(pole char)`"asdf" [~~a [~~s [~~d [~~f ~]]]] *** ### `++qual` Mold of 4 type tuple A `++qual` is a tuple of four of the types passed in. Source ------ ++ qual |* {a/$-(* *) b/$-(* *) c/$-(* *) d/$-(* *)} :: just a quadruple {p/a q/b r/c s/d} :: Examples -------- > *(qual date time tape cord) [p=[[a=%.y y=0] m=0 t=[d=0 h=0 m=0 s=0 f=~]] q=~292277024401-.1.1 r="" s=''] *** ### `++trap` Core with one arm `$` A trap is a core with one arm `++$`. Source ------ ++ trap |*(a/_* _|?(*a)) :: makes perfect sense Examples -------- > *trap <1.mws 101.jzo 1.ypj %164> > (*trap) 0 > (|.(42)) 42 *** ### `++tree` Tree mold generator A `++tree` can be empty, or contain a node of a type and left/right sub `++tree` of the same type. Pretty-printed with `{}`. Source ------ ++ tree |* a/$-(* *) :: binary tree $@($~ {n/a l/(tree a) r/(tree a)}) :: Examples -------- > `(tree {@ tape})`[[1 "hi"] [[2 "bye"] ~ ~] ~] {[2 "bye"] [1 "hi"]} *** ### `++trel` Mold of three types `++mold` of the tuple of the three types passed in. Source ------ ++ trel |* {a/$-(* *) b/$-(* *) c/$-(* *)} :: just a triple {p/a q/b r/c} :: Examples -------- > *(trel @ud @t @s) [p=0 q='' r=--0] *** ### `++unit` Maybe mold generator. A `++unit` is either `~` or `[~ u=a]` where `a` is the type that was passed in. Source ------ ++ unit |* a/$-(* *) :: maybe $@($~ {$~ u/a}) :: Examples -------- See also: `++bind` > ? *(unit time) ?({$~ u/@da} $~) ~ > > =a |= a/@ ^- (unit @) ?~ a ~ [~ a] > (a 2) [~ u=2] ***