on 140ac0e help sign in
146 lines 2.4 kB history raw
1# 2o: normalizing containers
2### `++jar`
5Tile generator. A `++jar` is a `++map` of `++list`.
7Source
8------
10 ++ jar |*({a/$-(* *) b/$-(* *)} (map a (list b))) :: map of lists
13Examples
14--------
16See also: `++ja`, `++by`, `++map`, `++list`
18 > =a (limo [1 2 ~])
19 > a
20 [i=1 t=[i=2 t=~]]
21 > =b (limo [3 4 ~])
22 > b
23 [i=3 t=[i=4 t=~]]
24 > =c (mo (limo [[%a a] [%b b] ~]))
25 > c
26 {[p=%a q=[i=1 t=[i=2 t=~]]] [p=%b q=[i=3 t=[i=4 t=~]]]}
27 > (~(get ja c) %a)
28 [i=1 t=[i=2 t=~]]
29 > (~(get ja c) %c)
30 ~
34***
35### `++jug`
37mold generator. A `++jug` is a `++map` of `++set`s.
39Source
40------
42 ++ jug |*({a/$-(* *) b/$-(* *)} (map a (set b))) :: map of sets
45Examples
46--------
48See also: `++ju`, `++by`, `++map`, `++set`
50 > =a (sa (limo [1 2 ~]))
51 > a
52 {1 2}
53 > =b (sa (limo [3 4 ~]))
54 > b
55 {4 3}
56 > =c (mo (limo [[%a a] [%b b] ~]))
57 > c
58 {[p=%a q={1 2}] [p=%b q={4 3}]}
59 > (~(get ju c) %b)
60 {4 3}
61 > (~(put ju c) [%b 5])
62 {[p=%a q={1 2}] [p=%b q={5 4 3}]}
65***
66### `++map`
68Map
70mold generator. A `++map` is a treap of
71key-value pairs.
74Source
75------
77 ++ map |* {a/$-(* *) b/$-(* *)} :: associative tree
78 $@($~ {n/{p/a q/b} l/(map a b) r/(map a b)}) ::
81Examples
82--------
84See also: `++by`
86 >? *(map @t @u)
87 nlr({p/@t q/@u})
88 {}
89 > (molt `(list (pair * *))`[[a+1 b+2] ~])
90 {[p=[97 1] q=[98 2]]}
93***
94### `++qeu`
96Queue
98mold generator. An ordered [treap](http://en.wikipedia.org/wiki/Treap) of
99items.
101Source
102------
104 ++ qeu |* a/$-(* *) :: queue
105 $@($~ {n/a l/(qeu a) r/(qeu a)}) ::
108Examples
109--------
111 > (qeu time)
112 <1.qyo [* <1.sxx [a=<1.ebd [* <101.jzo 1.ypj %164>]> <101.jzo 1.ypj %164>]>]>
113 > (~(gas to *(qeu time)) [~2014.1.1 ~2014.1.2 ~])
114 {~2014.1.2 ~2014.1.1}
118***
119### `++set`
121Set
123mold generator. A `++set` is a treap with unique values.
125Source
126------
128 ++ set |* a/$-(* *) :: set
129 $@($~ {n/a l/(set a) r/(set a)}) ::
132Examples
133--------
135See also: `++in`
137 > (sa "abc")
138 {~~a ~~c ~~b}
139 > (~(put in (sa "abc")) %d)
140 {~~d ~~a ~~c ~~b}
141 > (~(put in (sa "abc")) %a)
142 {~~a ~~c ~~b}
146***