on b00decd help sign in
108 lines 1.5 kB history raw
1+++
2title = "2l: Container from Container"
3weight = 15
4template = "doc.html"
5+++
7### `++malt`
9Map from list
11Produces a map from a list `a`.
13#### Accepts
15`a` is a list.
17#### Produces
19A map.
21#### Source
23```hoon
24++ malt :: map from list
25 |* a=(list)
26 (molt `(list [p=_-<.a q=_->.a])`a)
27```
29#### Examples
31```
32 > (malt [['ok' 'no'] ['a' 'b'] ['x' 'y'] ~])
33 [n=[p='x' q='y'] l={[p='a' q='b'] [p='ok' q='no']} r={}]
35 > (malt ~[[1 2 3] [4 5 6] [7 8 9]])
36 [n=[p=1 q=[2 3]] l={[p=4 q=[5 6]] [p=7 q=[8 9]]} r={}]
37```
39---
40### `++molt`
42Map from pair list
44Produces a map from a list of pairs `a`.
46#### Accepts
48`a` is a list of pairs.
50#### Produces
52A map.
54#### Source
56```hoon
57 ++ molt
58 |* a=(list (pair))
59 (~(gas by `(tree [p=_p.i.-.a q=_q.i.-.a})`~) a)
60```
62#### Examples
64```
65 > =a `(list (pair))`[[1 2] [4 3] [11 0] ~]
66 > a
67 > ~[[p=1 q=2] [p=4 q=3] [p=11 q=0]]
69 > (molt a)
70 [n=[p=11 q=0] l={[p=4 q=3] [p=1 q=2]} r={}]
71```
73#### Discussion
75Only used internally as a helper to `malt`.
77---
78### `++silt`
80Set from list
82Produces a set from a list `a`.
84#### Accepts
86`a` is a list.
88#### Produces
90A set.
92#### Source
94```hoon
95 ++ silt
96 |* a=(list)
97 =+ b=*(tree _?>(?=(^ a) i.a))
98 (~(gas in b) a)
99```
101#### Examples
103```
104 > (silt `(list @t)`['c' 'hoon' 'javascript' 'python' ~])
105 [n='javascript' l={} r={'python' 'hoon' 'c'}]
106```
108---