2j: Jar and Jug Logic
+ja
+jaJar engine.
A container arm for +jar operation arms. A +jar is a +map of +lists. The contained arms inherit the sample +jar.
Accepts
.a is a +jar.
Produces
A core.
Source
++ ja
=| a=(tree (pair * (list))) :: (jar)
|@Examples
> ~(. ja (my [a+1 b+2 ~]))
< 2.ngd
[ a
?(
%~
[ n=[?(p=%a p=%b) q=@ud]
l=nlr([p=?(%a %b) q=@ud])
r=nlr([p=?(%a %b) q=@ud])
]
)
<123.zao 46.hgz 1.pnw %140>
]
>+get:ja
+get:jaGrab value by key.
Produces the list at key .b in +jar .a.
Accepts
.a is a +jar, and is the sample of +ja.
.b is a $noun.
Produces
A +list.
Source
Examples
+add:ja
+add:jaPrepend to list.
Adds .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.
Accepts
.a is a +jar, and is the sample of +ja.
.b is a $noun of the same type as the keys in .a.
.c is a $noun of the same type the lists in .a contain.
Produces
A +jar.
Source
Examples
+ju
+juJug operations.
Container arm for jug operation arms. A +jug is a +map of +sets. The contained arms inherit its sample jug, .a.
Accepts
.a is a +jug.
Produces
A core.
Source
Example
+del:ju
+del:juRemove.
Produces jug .a with value .c removed from set located at key .b.
Accepts
.a is a jug, and is the sample of +ju.
.b is a $noun of the same type as the keys in .a.
.c is a $noun of the same type as the sets in .a contain.
Source
Examples
+gas:ju
+gas:juConcatenate.
Add 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.
Accepts
.a is a +jug, and is the sample of +ju.
.b is a (list [p q]), where:
.pis a$noun, the type of the keys in.a..qis a$noun, the type the sets in.acontain.
Produces
A +jug.
Source
Examples
+get:ju
+get:juRetrieve set.
Produces a set retrieved from jug .a using key .b.
Accepts
.a is a jug, and the sample of +ju.
.b is key, a $noun of the same type as the keys in .a.
Produces
A +set.
Source
Examples
+has:ju
+has:juCheck contents.
Computes whether a value .c exists within the set located at key .b with jug .a, producing a $flag.
Accepts
.a is a +jug, and the sample of +ju.
.b is a $noun of the same type as the keys in .a.
.c is a $noun of the same type as the sets in .a contain.
Produces
A $flag.
Source
Examples
+put:ju
+put:juAdd key-set pair.
Produces 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.
Accepts
.a is a +jug.
.b is a $noun, the type of the keys in .a.
.c is a $noun, the type the sets in .a contain.
Produces
A +jug.
Source
Examples
Last updated