on 6d45ede help sign in
151 lines 2.4 kB history raw
1---
2navhome: /docs
3---
6# 2o: normalizing containers
7### `++jar`
10Tile generator. A `++jar` is a `++map` of `++list`.
12Source
13------
15 ++ jar |*({a/$-(* *) b/$-(* *)} (map a (list b))) :: map of lists
18Examples
19--------
21See also: `++ja`, `++by`, `++map`, `++list`
23 > =a (limo [1 2 ~])
24 > a
25 [i=1 t=[i=2 t=~]]
26 > =b (limo [3 4 ~])
27 > b
28 [i=3 t=[i=4 t=~]]
29 > =c (mo (limo [[%a a] [%b b] ~]))
30 > c
31 {[p=%a q=[i=1 t=[i=2 t=~]]] [p=%b q=[i=3 t=[i=4 t=~]]]}
32 > (~(get ja c) %a)
33 [i=1 t=[i=2 t=~]]
34 > (~(get ja c) %c)
35 ~
39***
40### `++jug`
42mold generator. A `++jug` is a `++map` of `++set`s.
44Source
45------
47 ++ jug |*({a/$-(* *) b/$-(* *)} (map a (set b))) :: map of sets
50Examples
51--------
53See also: `++ju`, `++by`, `++map`, `++set`
55 > =a (sa (limo [1 2 ~]))
56 > a
57 {1 2}
58 > =b (sa (limo [3 4 ~]))
59 > b
60 {4 3}
61 > =c (mo (limo [[%a a] [%b b] ~]))
62 > c
63 {[p=%a q={1 2}] [p=%b q={4 3}]}
64 > (~(get ju c) %b)
65 {4 3}
66 > (~(put ju c) [%b 5])
67 {[p=%a q={1 2}] [p=%b q={5 4 3}]}
70***
71### `++map`
73Map
75mold generator. A `++map` is a treap of
76key-value pairs.
79Source
80------
82 ++ map |* {a/$-(* *) b/$-(* *)} :: associative tree
83 $@($~ {n/{p/a q/b} l/(map a b) r/(map a b)}) ::
86Examples
87--------
89See also: `++by`
91 >? *(map @t @u)
92 nlr({p/@t q/@u})
93 {}
94 > (molt `(list (pair * *))`[[a+1 b+2] ~])
95 {[p=[97 1] q=[98 2]]}
98***
99### `++qeu`
101Queue
103mold generator. An ordered [treap](http://en.wikipedia.org/wiki/Treap) of
104items.
106Source
107------
109 ++ qeu |* a/$-(* *) :: queue
110 $@($~ {n/a l/(qeu a) r/(qeu a)}) ::
113Examples
114--------
116 > (qeu time)
117 <1.qyo [* <1.sxx [a=<1.ebd [* <101.jzo 1.ypj %164>]> <101.jzo 1.ypj %164>]>]>
118 > (~(gas to *(qeu time)) [~2014.1.1 ~2014.1.2 ~])
119 {~2014.1.2 ~2014.1.1}
123***
124### `++set`
126Set
128mold generator. A `++set` is a treap with unique values.
130Source
131------
133 ++ set |* a/$-(* *) :: set
134 $@($~ {n/a l/(set a) r/(set a)}) ::
137Examples
138--------
140See also: `++in`
142 > (sa "abc")
143 {~~a ~~c ~~b}
144 > (~(put in (sa "abc")) %d)
145 {~~d ~~a ~~c ~~b}
146 > (~(put in (sa "abc")) %a)
147 {~~a ~~c ~~b}
151***