on dc20522 help sign in
111 lines 1.4 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:- :~ navhome/'/docs/'
25 sort/'14'
26 title/'2k: Jar and Jug Logic'
27 ==
29;>
30```
32#### Examples
34```
35 > (malt [['ok' 'no'] ['a' 'b'] ['x' 'y'] ~])
36 [n=[p='x' q='y'] l={[p='a' q='b'] [p='ok' q='no']} r={}]
38 > (malt ~[[1 2 3] [4 5 6] [7 8 9]])
39 [n=[p=1 q=[2 3]] l={[p=4 q=[5 6]] [p=7 q=[8 9]]} r={}]
40```
42---
43### `++molt`
45Map from pair list
47Produces a map from a list of pairs `a`.
49#### Accepts
51`a` is a list of pairs.
53#### Produces
55A map.
57#### Source
59```hoon
60 ++ molt
61 |* a=(list (pair))
62 (~(gas by `(tree [p=_p.i.-.a q=_q.i.-.a})`~) a)
63```
65#### Examples
67```
68 > =a `(list (pair))`[[1 2] [4 3] [11 0] ~]
69 > a
70 > ~[[p=1 q=2] [p=4 q=3] [p=11 q=0]]
72 > (molt a)
73 [n=[p=11 q=0] l={[p=4 q=3] [p=1 q=2]} r={}]
74```
76#### Discussion
78Only used internally as a helper to `malt`.
80---
81### `++silt`
83Set from list
85Produces a set from a list `a`.
87#### Accepts
89`a` is a list.
91#### Produces
93A set.
95#### Source
97```hoon
98 ++ silt
99 |* a=(list)
100 =+ b=*(tree _?>(?=(^ a) i.a))
101 (~(gas in b) a)
102```
104#### Examples
106```
107 > (silt `(list @t)`['c' 'hoon' 'javascript' 'python' ~])
108 [n='javascript' l={} r={'python' 'hoon' 'c'}]
109```
111---