on b93c19b help sign in
110 lines 1.4 kB history raw
1+++
2title = "2l: Container from Container"
3weight = 15
4template = "doc.html"
5+++
6### `++malt`
8Map from list
10Produces a map from a list `a`.
12#### Accepts
14`a` is a list.
16#### Produces
18A map.
20#### Source
22```
23:- :~ navhome/'/docs/'
24 sort/'14'
25 title/'2k: Jar and Jug Logic'
26 ==
28;>
29```
31#### Examples
33```
34 > (malt [['ok' 'no'] ['a' 'b'] ['x' 'y'] ~])
35 [n=[p='x' q='y'] l={[p='a' q='b'] [p='ok' q='no']} r={}]
37 > (malt ~[[1 2 3] [4 5 6] [7 8 9]])
38 [n=[p=1 q=[2 3]] l={[p=4 q=[5 6]] [p=7 q=[8 9]]} r={}]
39```
41---
42### `++molt`
44Map from pair list
46Produces a map from a list of pairs `a`.
48#### Accepts
50`a` is a list of pairs.
52#### Produces
54A map.
56#### Source
58```
59 ++ molt
60 |* a=(list (pair))
61 (~(gas by `(tree [p=_p.i.-.a q=_q.i.-.a})`~) a)
62```
64#### Examples
66```
67 > =a `(list (pair))`[[1 2] [4 3] [11 0] ~]
68 > a
69 > ~[[p=1 q=2] [p=4 q=3] [p=11 q=0]]
71 > (molt a)
72 [n=[p=11 q=0] l={[p=4 q=3] [p=1 q=2]} r={}]
73```
75#### Discussion
77Only used internally as a helper to `malt`.
79---
80### `++silt`
82Set from list
84Produces a set from a list `a`.
86#### Accepts
88`a` is a list.
90#### Produces
92A set.
94#### Source
96```
97 ++ silt
98 |* a=(list)
99 =+ b=*(tree _?>(?=(^ a) i.a))
100 (~(gas in b) a)
101```
103#### Examples
105```
106 > (silt `(list @t)`['c' 'hoon' 'javascript' 'python' ~])
107 [n='javascript' l={} r={'python' 'hoon' 'c'}]
108```
110---