2title = "2j: Jar and Jug Logic"
11A container arm for `jar` operation arms. A `jar` is a `map` of
12`list`s. The contained arms inherit the sample jar.
26 =| a=(tree (pair * (list))) :: (jar)
33> ~(. ja (my [a+1 b+2 ~]))
38 [ n=[?(p=%a p=%b) q=@ud]
39 l=nlr([p=?(%a %b) q=@ud])
40 r=nlr([p=?(%a %b) q=@ud])
43 <123.zao 46.hgz 1.pnw %140>
54Produces the list at key `b` in jar `a`.
58`a` is a `jar`, and is the sample of `+ja`.
78> =j `(jar @t @ud)`(malt ~[['a' `(list @ud)`~[1 2 3]] ['b' `(list @ud)`~[4 5 6]]])
80{[p='b' q=~[4 5 6]] [p='a' q=~[1 2 3]]}
82> `(list @ud)`(~(get ja j) 'a')
85> `(list @ud)`(~(get ja j) 'b')
88> `(list @ud)`(~(get ja j) 'c')
98Adds `c` to the head of the list at key `b` in jar `a`. If `b` does not exist in `a`, a new key-value pair is added with a list containing `c`.
102`a` is a `jar`, and is the sample of `+ja`.
104`b` is a noun of the same type as the keys in `a`.
106`c` is a noun of the same type the lists in `a` contain.
118 (~(put by a) b [c d])
124> =j `(jar @t @ud)`(malt ~[['a' `(list @ud)`~[1 2 3]] ['b' `(list @ud)`~[4 5 6]]])
126{[p='b' q=~[4 5 6]] [p='a' q=~[1 2 3]]}
128> `(jar @t @ud)`(~(add ja j) 'b' 7)
129{[p='b' q=~[7 4 5 6]] [p='a' q=~[1 2 3]]}
131> `(jar @t @ud)`(~(add ja j) 'c' 8)
132{[p='b' q=~[4 5 6]] [p='a' q=~[1 2 3]] [p='c' q=~[8]]}
141Container arm for jug operation arms. A `jug` is a `map` of
142`set`s. The contained arms inherit its sample jug, `a`.
156 =| a=(tree (pair * (tree))) :: (jug)
163> =j `(jug @t @ud)`(malt ~[['a' (silt ~[1 2 3])] ['b' (silt ~[4 5 6])]])
165{[p='b' q={5 6 4}] [p='a' q={1 2 3}]}
168<5.cws [a=nlr([p=@t q=nlr(@ud)]) <123.zao 46.hgz 1.pnw %140>]>
177Produces jug `a` with value `c` removed from set located at key `b`.
181`a` is a jug, and is the sample of `+ju`.
183`b` is a noun of the same type as the keys in `a`.
185`c` is a noun of the same type as the sets in `a` contain.
204{[p='b' q={5 6 4}] [p='a' q={1 2 3}]}
206> `(jug @t @ud)`(~(del ju j) 'b' 6)
207{[p='b' q={5 4}] [p='a' q={1 2 3}]}
209> `(jug @t @ud)`(~(del ju j) 'b' 10)
210{[p='b' q={5 6 4}] [p='a' q={1 2 3}]}
212> `(jug @t @ud)`(~(del ju j) 'c' 10)
213{[p='b' q={5 6 4}] [p='a' q={1 2 3}]}
222Add each of the key-value pairs in list `b` to jug `a`. The values in `b` are the type the sets in `a` contain. For keys in `b` that exist in `a`, the values will be added to their sets. For keys in `b` that don't exist in `a`, new keys and sets will be added.
226`a` is a `jug`, and is the sample of `+ju`.
228`b` is a `(list [p q])`, where:
230- `p` is a noun, the type of the keys in `a`.
231- `q` is a noun, the type the sets in `a` contain.
241 |* b=(list [p=* q=*])
242 => .(b `(list _?>(?=([[* ^] ^] a) [p=p q=n.q]:n.a))`b)
246 $(b t.b, a (put p.i.b q.i.b))
252> =j `(jug @t @ud)`(malt ~[['a' (silt ~[1 2 3])] ['b' (silt ~[4 5 6])]])
254{[p='b' q={5 6 4}] [p='a' q={1 2 3}]}
256> `(jug @t @ud)`(~(gas ju j) ~[['a' 10] ['a' 42] ['b' 999] ['c' 7]])
257{[p='b' q={5 6 4 999}] [p='a' q={10 42 1 2 3}] [p='c' q={7}]}
266Produces a set retrieved from jug `a` using key `b`.
270`a` is a jug, and the sample of `+ju`.
272`b` is key, a noun of the same type as the keys in `a`.
290> =j `(jug @t @ud)`(malt ~[['a' (silt ~[1 2 3])] ['b' (silt ~[4 5 6])]])
292{[p='b' q={5 6 4}] [p='a' q={1 2 3}]}
294> `(set @ud)`(~(get ju j) 'a')
297> `(set @ud)`(~(get ju j) 'b')
300> `(set @ud)`(~(get ju j) 'c')
310Computes whether a value `c` exists within the set located at key `b`
311with jug `a`, producing a flag.
315`a` is a `jug`, and the sample of `+ju`.
317`b` is a noun of the same type as the keys in `a`.
319`c` is a noun of the same type as the sets in `a` contain.
331 (~(has in (get b)) c)
337> =j `(jug @t @ud)`(malt ~[['a' (silt ~[1 2 3])] ['b' (silt ~[4 5 6])]])
339{[p='b' q={5 6 4}] [p='a' q={1 2 3}]}
344> (~(has ju j) 'b' 10)
347> (~(has ju j) 'c' 10)
357Produces jug `a` with `c` added to the set located at key `b`. If `b` isn't a key in `a`, it will be added and a new set created containing `c`.
363`b` is a noun, the type of the keys in `a`.
365`c` is a noun, the type the sets in `a` contain.
378 (~(put by a) b (~(put in d) c))
385{[p='b' q={5 6 4}] [p='a' q={1 2 3}]}
387> `(jug @t @ud)`(~(put ju j) 'c' 5)
388{[p='b' q={5 6 4}] [p='a' q={1 2 3}] [p='c' q={5}]}
390> `(jug @t @ud)`(~(put ju j) 'a' 4)
391{[p='b' q={5 6 4}] [p='a' q={1 2 3 4}]}
393> `(jug @t @ud)`(~(put ju j) 'a' 1)
394{[p='b' q={5 6 4}] [p='a' q={1 2 3}]}
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list