on 4fdc19d help sign in
110 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---
41## `++molt`
43Map from pair list
45Produces a map from a list of pairs `a`.
47#### Accepts
49`a` is a list of pairs.
51#### Produces
53A map.
55#### Source
57```hoon
58 ++ molt
59 |* a=(list (pair))
60 (~(gas by `(tree [p=_p.i.-.a q=_q.i.-.a})`~) a)
61```
63#### Examples
65```
66 > =a `(list (pair))`[[1 2] [4 3] [11 0] ~]
67 > a
68 > ~[[p=1 q=2] [p=4 q=3] [p=11 q=0]]
70 > (molt a)
71 [n=[p=11 q=0] l={[p=4 q=3] [p=1 q=2]} r={}]
72```
74#### Discussion
76Only used internally as a helper to `malt`.
78---
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```hoon
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---