@@ -8,88 +8,288 @@ navhome: /docs/
88
99Map operations
1010
11− ++ by :: map engine
12− ~/ %by
13− |_ a/(map)
14−
11+Container arm for map operation arms. A map is a set of key-value pairs. The
12+contained arms inherit it's sample map, `a`.
1513
16−Container arm for map operation arms. A map is a set of key, value
17−pairs. The contained arms inherit it's sample map, `a`.
14+### Accepts
1815
1916`a` is a map.
2017
21− > ~(. by (my [%a 1] [%b 2] ~))
22− <22.znh {a/nlr({p/?($a $b) q/@ud}) <409.ofg 110.xht 1.ztu $151>}>
18+#### Source
19+
20+ ++ by
21+ ~/ %by
22+ =| a=(tree (pair))
23+ =* node ?>(?=(^ a) n.a)
24+
25+#### Examples
2326
24−------------------------------------------------------------------------
27+ > ~(. by (my [%a 1] [%b 2] ~))
28+ < 27.zjr
29+ { a
30+ ?(
31+ { n/{?(p/$a p/$b) q/@ud}
32+ l/nlr({p/?($b $a) q/@ud})
33+ r/nlr({p/?($b $a) q/@ud})
34+ }
35+ $~
36+ )
37+ <119.wim 31.ohr 1.jmk $143>
38+ }
2539
40+***
2641### `+-all:by`
2742
2843Logical AND
2944
30− +- all :: logical AND
45+Computes the logical AND on the results of slamming every element in map `a`
46+with gate `b`.
47+
48+#### Accepts
49+
50+`a` is a map.
51+
52+`b` is a wet gate.
53+
54+#### Produces
55+
56+A flag.
57+
58+#### Source
59+
60+ +- all
3161 ~/ %all
32− |* b/$-(* ?)
62+ |* b=$-(* ?)
3363 |- ^- ?
3464 ?~ a
3565 &
3666 ?&((b q.n.a) $(a l.a) $(a r.a))
37− ::
38−
3967
40−Computes the logical AND on the results of slamming every element in map
41−`a` with gate `b`. Produces a loobean.
42−
43−`a` is a map.
44−
45−`b` is a wet gate.
68+#### Examples
4669
4770 > =b (my [['a' 1] ['b' [2 3]] ~])
48− > (~(all by b) |=(a/* ?@(a & |)))
71+ > (~(all by b) |=(a=* ?@(a & |)))
4972 %.n
73+
5074 > =a (my [['a' 1] ['b' 2] ['c' 3] ['d' 4] ['e' 5] ~])
51− > (~(all by a) |=(a/@ (lte a 6)))
75+ > (~(all by a) |=(a=@ (lte a 6)))
5276 %.y
53− > (~(all by a) |=(a/@ (lte a 4)))
54− %.n
5577
56−------------------------------------------------------------------------
78+ > (~(all by a) |=(a=@ (lte a 4)))
79+ %.n
5780
81+***
5882### `+-any:by`
5983
6084Logical OR
6185
62− +- any :: logical OR
86+Computes the logical OR on the results of slamming every element with
87+gate `b`.
88+
89+#### Accepts
90+
91+`a` is a map.
92+
93+`b` is a wet gate.
94+
95+#### Produces
96+
97+A flag.
98+
99+#### Source
100+
101+ +- any
63102 ~/ %any
64− |* b=$+(* ?)
103+ |* b=$-(* ?)
65104 |- ^- ?
66105 ?~ a
67106 |
68107 ?|((b q.n.a) $(a l.a) $(a r.a))
69108
70−Computes the logical OR on the results of slamming every element with
71−gate `b`. Produces a loobean.
72−
73−`a` is a map.
74−
75−`b` is a wet gate.
109+#### Examples
76110
77111 > =b (my [['a' 1] ['b' [2 3]] ~])
78− > (~(any by b) |=(a/* ?@(a & |)))
112+ > (~(any by b) |=(a=* ?@(a & |)))
79113 %.y
114+
80115 > =a (my [['a' 1] ['b' 2] ['c' 3] ['d' 4] ['e' 5] ~])
81− > (~(any by a) |=(a/@ (lte a 4)))
116+ > (~(any by a) |=(a=@ (lte a 4)))
82117 %.y
83118
84−------------------------------------------------------------------------
119+***
120+###`+-apt:by`
121+
122+Check correctness
123+
124+Computes whether `a` has a correct horizontal order and a correct vertical
125+order, producing a flag.
126+
127+#### Accepts
128+
129+`a` is a map.
130+
131+#### Produces
132+
133+A flag.
134+
135+#### Source
136+
137+ +- apt
138+ =| [l=(unit) r=(unit)]
139+ |- ^- ?
140+ ?~ a &
141+ ?& ?~(l & (gor p.n.a u.l))
142+ ?~(r & (gor u.r p.n.a))
143+ ?~(l.a & ?&((vor p.n.a p.n.l.a) $(a l.a, l `p.n.a)))
144+ ?~(r.a & ?&((vor p.n.a p.n.r.a) $(a r.a, r `p.n.a)))
145+ ==
146+
147+#### Examples
148+
149+ > =a (my [['a' 1] ['b' [2 3]] ~])
150+ > ~(apt by a)
151+ %.y
152+
153+ > =s (my [[1 2] [3 4] ~])
154+ > =z ?~ s ~ s(p.n 10)
155+ > z
156+ [n=[p=10 q=2] l={} r={[p=3 q=4]}]
157+
158+ > ~(apt by z)
159+ %.n
160+
161+#### Discussion
162+
163+See section [`2f`](../2f) for more information on noun ordering.
164+
165+###`+-bif:by`
166+
167+Bifurcate
168+
169+Splits set `a` into two sets `l` and `r`, with the head at `b` discarded.
170+
171+#### Accepts
172+
173+`a` is a map.
174+
175+`b` is a noun.
176+
177+`c` is a noun.
178+
179+#### Produces
180+
181+A cell of two maps.
182+
183+#### Source
184+
185+ +- bif
186+ ~/ %bif
187+ |* [b=* c=*]
188+ ^+ [l=a r=a]
189+ =< +
190+ |- ^+ a
191+ ?~ a
192+ [[b c] ~ ~]
193+ ?: =(b p.n.a)
194+ ?: =(c q.n.a)
195+ a
196+ [[b c] l.a r.a]
197+ ?: (gor b p.n.a)
198+ =+ d=$(a l.a)
199+ ?> ?=(^ d)
200+ [n.d l.d [n.a r.d r.a]]
201+ =+ d=$(a r.a)
202+ ?> ?=(^ d)
203+ [n.d [n.a l.a l.d] r.d]
204+
205+#### Examples
206+
207+ > =a (my [['a' 1] ['b' 2] ['c' 3] ~])
208+
209+ > (~(bif by a) ['b' 2])
210+ [l=[n=[p='c' q=3] l=[n=[p='a' q=1] l={} r={}] r=~] r=~]
211+
212+
213+###`+-def:by`
214+
215+Difference
85216
217+#### Accepts
218+
219+`a` is a map.
220+
221+`b` is a map.
222+
223+#### Produces
224+
225+A map.
226+
227+#### Source
228+
229+ +- def
230+ |* b=_a
231+ ^- (map _p:node (pair (unit _q:node) (unit _q:node)))
232+ !!
233+
234+#### Examples
235+
236+***
237+###`+-dep`
238+
239+Difference as patch
240+
241+
242+#### Accepts
243+
244+`a` is a map.
245+
246+`b` is a map.
247+
248+#### Produces
249+
250+A cell of maps.
251+
252+#### Source
253+
254+ +- dep
255+ |* b=_a
256+ ^+ [p=a q=a]
257+ =+ c=~(tap by (def b))
258+ =+ [d e]=[`_a`~ `_a`~]
259+ |- ^+ [d e]
260+ ?~ c [d e]
261+ %= $
262+ c t.c
263+ d ?~(q.q.i.c d (~(put by d) p.i.c u.q.q.i.c))
264+ e ?~(p.q.i.c e (~(put by e) p.i.c u.p.q.i.c))
265+ ==
266+
267+#### Examples
268+
269+
270+
271+***
86272### `+-del:by`
87273
88274Delete
89275
90− +- del :: delete at key b
276+Produces map `a` with the element located at key `b` removed.
277+
278+#### Accepts
279+
280+`a` is a map.
281+
282+`b` is a key as a noun.
283+
284+#### Produces
285+
286+A map.
287+
288+#### Source
289+
290+ +- del
91291 ~/ %del
92− |* b/*
292+ |* b=*
93293 |- ^+ a
94294 ?~ a
95295 ~
@@ -97,32 +297,40 @@ Delete
97297 ?: (gor b p.n.a)
98298 [n.a $(a l.a) r.a]
99299 [n.a l.a $(a r.a)]
100− |- ^- {$?($~ _a)}
300+ |- ^- [(~ _a)]
101301 ?~ l.a r.a
102302 ?~ r.a l.a
103303 ?: (vor p.n.l.a p.n.r.a)
104304 [n.l.a l.l.a $(l.a r.l.a)]
105305 [n.r.a $(r.a l.r.a) r.r.a]
106− ::
107306
108−Produces map `a` with the element located at key `b` removed.
307+#### Examples
308+
309+ > =b (my [['a' 1] ['b' [2 3]] ~])
310+ > (~(del by b) 'a')
311+ [n=[p='b' q=[2 3]] l=~ r=~]
312+
313+***
314+### `+-dig:by`
315+
316+Address of key
317+
318+Produce the address of key `b` within map `a`.
319+
320+#### Accepts
109321
110322`a` is a map.
111323
112324`b` is a key as a noun.
113325
114− > =b (my [['a' 1] ['b' [2 3]] ~])
115− > (~(del by b) 'a')
116− {[p='b' q=[2 3]]}
326+#### Produces
117327
118−------------------------------------------------------------------------
328+A unit.
119329
120−### `+-dig:by`
121−
122−Axis of key
330+#### Source
123331
124− +- dig :: axis of b key
125− |= b/*
332+ +- dig
333+ |= b=*
126334 =+ c=1
127335 |- ^- (unit @)
128336 ?~ a ~
@@ -130,56 +338,74 @@ Axis of key
130338 ?: (gor b p.n.a)
131339 $(a l.a, c (peg c 6))
132340 $(a r.a, c (peg c 7))
133− ::
134−
135341
136−Produce the axis of key `b` within map `a`.
137342
138−`a` is a map.
139−
140−`b` is a key as a noun.
343+#### Examples
141344
142345 > =b (my [['a' 1] ['b' [2 3]] ~])
143346 > (~(dig by b) 'b')
144− [~ 2]
145−
146−------------------------------------------------------------------------
347+ [~ u=2]
147348
349+***
148350### `+-gas:by`
149351
150352Concatenate
151353
152− +- gas :: concatenate
153− ~/ %gas
154− |= b/(list _?>(?=(^ a) n.a))
155− |- ^+ a
156− ?~ b
157− a
158− $(b t.b, a (put i.b))
159− ::
160−
161−
162354Insert a list of key-value pairs `b` into map `a`.
163355
356+#### Accepts
357+
164358`a` is a map.
165359
166360`b` is a list of cells of key-value nouns `p` and `q`.
167361
362+#### Produces
363+
364+A map.
365+
366+#### Source
367+
368+ +- gas
369+ ~/ %gas
370+ |* b=(list [p=* q=*])
371+ => .(b `(list _?>(?=(^ a) n.a))`b)
372+ |- ^+ a
373+ ?~ b
374+ a
375+ $(b t.b, a (put p.i.b q.i.b))
376+
377+#### Examples
378+
168379 > =a (my [['a' 1] ['b' 2] ~])
169380 > =b [['c' 3] ['d' 4] ~]
170− > (~(gas by a) b)
171− {[p='d' q=4] [p='a' q=1] [p='c' q=3] [p='b' q=2]}
172381
173−------------------------------------------------------------------------
382+ > (~(gas by a) b)
383+ [n=[p='b' q=2] l=[n=[p='d' q=4] l={} r={[p='a' q=1] [p='c' q=3]}] r=~]
174384
385+***
175386### `+-get:by`
176387
177388Grab unit value
178389
179− +- get :: unit value by key
390+Produce the unit value of the value located at key `b` within map `a`.
391+
392+#### Accepts
393+
394+`a` is a map.
395+
396+`b` is a key as a noun.
397+
398+#### Produces
399+
400+A unit.
401+
402+#### Source
403+
404+ +- get
180405 ~/ %get
181− |* b=*
182− |- ^- ?(~ [~ u=_?>(?=(^ a) q.n.a)])
406+ |= b=*
407+ ^- [$@(~ [~ u=_?>(?=(^ a) q.n.a)])]
408+ =+ 42
183409 ?~ a
184410 ~
185411 ?: =(b p.n.a)
@@ -188,77 +414,112 @@ Grab unit value
188414 $(a l.a)
189415 $(a r.a)
190416
191−Produce the unit value of the value located at key `b` within map `a`.
417+#### Examples
192418
193−`a` is a map
419+ > =b (my [['a' 1] ['b' [2 3]] ~])
420+ > (~(get by b) 'b')
421+ [~ u=[2 3]]
194422
195−`b` is a key as a noun
196423
197− > =b (my [['a' 1] ['b' [2 3]] ~])
198− > (~(get by b) 'b')
199− [~ [2 3]]
424+ > =m (my [['a' 1] ['b' 2] ~])
425+ > (~(get by m) 'a')
426+ [~ u=1]
200427
201−------------------------------------------------------------------------
202428
429+***
203430### `+-got:by`
204431
205432Assert
206433
434+Produce the value located at key `b` within map `a`. Crash if key `b` does not
435+exist.
436+
437+#### Accepts
438+
439+`a` is a map.
440+
441+`b` is a key as a noun.
442+
443+#### Produces
444+
445+A noun.
446+
447+#### Source
448+
207449 +- got
208− |* b/*
450+ |* b=*
209451 (need (get b))
210452
211−Produce the value located at key `b` within map `a`. Crash if key `b`
212−does not exist.
453+#### Examples
213454
214−`a` is a map.
455+ > =m (my [['a' 1] ['b' 2] ~])
456+ > m
457+ [n=[p='b' q=2] l={[p='a' q=1]} r={}]
215458
216−`b` is a key.
459+ > (~(got by m) 'a')
460+ 1
217461
218− > =m (my [['a' 1] ['b' 2] ~])
219− > m
220− {[p='a' q=1] [p='b' q=2]}
221− > (~(get by m) 'a')
222− [~ 1]
223− > (~(got by m) 'a')
224− 1
225− > (~(got by m) 'c')
226− ! exit
462+ > (~(got by m) 'c')
463+ ! exit
227464
228−------------------------------------------------------------------------
229465
466+***
230467### `+-has:by`
231468
232469Key existence check
233470
234− +- has :: key existence check
235− ~/ %has
236− |* b/*
237− !=(~ (get b))
471+Checks whether map `a` contains an element with key `b`, producing a flag.
238472
239−
240−Checks whether map `a` contains an element with key `b`, producing a
241−loobean.
473+#### Accepts
242474
243475`a` is a map.
244476
245477`b` is a key as a noun.
246478
247− > =b (my [['a' 1] ['b' [2 3]] ~])
248− > (~(has by b) 'b')
249− %.y
250− > (~(has by b) 'c')
251− %.n
479+#### Produces
480+
481+A flag.
252482
253−------------------------------------------------------------------------
483+#### Source
254484
485+ +- has
486+ ~/ %has
487+ |* b=*
488+ !=(~ (get b))
489+
490+#### Examples
491+
492+ > =b (my [['a' 1] ['b' [2 3]] ~])
493+ > (~(has by b) 'b')
494+ %.y
495+
496+ > (~(has by b) 'c')
497+ %.n
498+
499+***
255500### `+-int:by`
256501
257502Intersection
258503
259− +- int :: intersection
504+Produces a map of the (key) intersection between two maps of the same type, `a`
505+and `b`. If both maps have an identical key that point to different values, the
506+element from map `b` is used.
507+
508+#### Accepts
509+
510+`a` is a map.
511+
512+`b` is a map.
513+
514+#### Produces
515+
516+A map.
517+
518+#### Source
519+
520+ +- int
260521 ~/ %int
261− |* b/_a
522+ |* b=_a
262523 |- ^+ a
263524 ?~ b
264525 ~
@@ -275,83 +536,98 @@ Intersection
275536 ?: (gor p.n.a p.n.b)
276537 %- uni(a $(b l.b, a [n.a l.a ~])) $(a r.a)
277538 %- uni(a $(b r.b, a [n.a ~ r.a])) $(a l.a)
278− ::
279539
280−Produces a map of the (key) intersection between two maps of the same
281−type, `a` and `b`. If both maps have an identical key that point to
282−different values, the element from map `b` is used.
540+#### Examples
283541
284−`a` is a map.
542+ > =n (my [['a' 1] ['c' 3] ~])
543+ > =m (my [['a' 1] ['b' 2] ~])
285544
286−`b` is a map.
545+ > (~(int by m) n)
546+ [n=[p='a' q=1] l=~ r=~]
547+
548+ > =p (my [['a' 2] ['b' 2] ~])
549+ > p
550+ [n=[p='b' q=2] l={[p='a' q=2]} r={}]
551+ > (~(int by p) n)
552+ [n=[p='a' q=1] l=~ r=~]
553+
554+ > =q (my [['a' 2] ['c' 2] ~])
555+ > q
556+ [n=[p='c' q=2] l={[p='a' q=2]} r={}]
557+ > (~(int by p) q)
558+ [n=[p='a' q=2] l=~ r=~]
287559
288− > =n (my [['a' 1] ['c' 3] ~])
289− > n
290− {[p='a' q=1] [p='c' q=3]}
291− > m
292− {[p='a' q=1] [p='b' q=2]}
293− > (~(int by m) n)
294− {[p='a' q=1]}
295− > =p (my [['a' 2] ['b' 2] ~])
296− > p
297− {[p='a' q=2] [p='b' q=2]}
298− > (~(int by p) n)
299− {[p='a' q=1]}
300− > =q (my [['a' 2] ['c' 2] ~])
301− > q
302− {[p='a' q=2] [p='c' q=2]}
303− > (~(int by p) q)
304− {[p='a' q=2]}
305− > =o (my [['c' 3] ['d' 4] ~])
306− > (~(int by m) o)
307− {}
308−
309−
310−------------------------------------------------------------------------
560+ > =o (my [['c' 3] ['d' 4] ~])
561+ > (~(int by m) o)
562+ ~
311563
564+
565+***
312566### `+-mar:by`
313567
314−Assert and Add
568+Assert and add
569+
570+Produces map `a` with the addition of a key-value pair, where the value is a
571+nonempty unit.
315572
316− +- mar :: add with validation
573+Accept a noun and a unit of a noun of the type of the map's keys and values,
574+respectively. Validate that the value is not null and put the pair in the map.
575+If the value is null, delete the key.
576+
577+#### Accepts
578+
579+`a` is a map.
580+
581+`b` is a unit.
582+
583+#### Produces
584+
585+A map.
586+
587+#### Assert and Add
588+
589+ +- mar
317590 |* [b=_?>(?=(^ a) p.n.a) c=(unit ,_?>(?=(^ a) q.n.a))]
318591 ?~ c
319592 (del b)
320593 (put b u.c)
321594
322−Produces map `a` with the addition of a key-value pair, where the value
323−is a nonempty unit.
324−
325−Accept a noun and a unit of a noun of the type of the map's keys and
326−values, respectively. Validate that the value is not null and put the
327−pair in the map. If the value is null, delete the key.
595+#### Examples
328596
329−XX This arm is broken, asana task 15186618346453
597+ > =m (my [['a' 1] ['b' 2] ~])
598+ > (~(mar by m) 'c' (some 3))
599+ [n=[p='b' q=2] l=[n=[p='c' q=3] l=[n=[p='a' q=1] l={} r={}] r=~] r=~]
330600
331− > m
332− {[p='a' q=1] [p='b' q=2]}
333− > (~(mar by m) 'c' (some 3))
334− ! -find-limb.n
335− ! find-none
336− ! exit
337− > (~(mar by m) 'c' ~)
338− ! -find-limb.n
339− ! find-none
340− ! exit
341− > (~(mar by m) 'b' ~)
342− ! -find-limb.n
343− ! find-none
344− ! exit
601+ > (~(mar by m) 'c' ~)
602+ [n=[p='b' q=2] l=[n=[p='a' q=1] l=~ r=~] r=~]
345603
346−------------------------------------------------------------------------
604+ > (~(mar by m) 'b' ~)
605+ [n=[p='a' q=1] l=~ r=~]
347606
607+***
348608### `+-put:by`
349609
350610Add key-value pair
351611
352− +- put :: adds key-value pair
612+Produces `a` with the addition of the key-value pair of `b` and `c`.
613+
614+#### Accepts
615+
616+`a` is a map.
617+
618+`b` is a key of the same type as the keys in `a`.
619+
620+`c` is a value of the same type of the values in `a`.
621+
622+#### Produces
623+
624+A map.
625+
626+#### Source
627+
628+ +- put
353629 ~/ %put
354− |* {b/* c/*}
630+ |* [b=* c=*]
355631 |- ^+ a
356632 ?~ a
357633 [[b c] ~ ~]
@@ -370,47 +646,77 @@ Add key-value pair
370646 ?: (vor p.n.a p.n.d)
371647 [n.a l.a d]
372648 [n.d [n.a l.a l.d] r.d]
373− ::
374649
375−Produces `a` with the addition of the key-value pair of `b` and `c`.
650+#### Examples
376651
377−`a` is a map.
378−
379−`b` is a key of the same type as the keys in `a`.
652+ > =m (my [['a' 1] ['b' 2] ~])
653+ > (~(put by ~) 'c' 3)
654+ [n=[p='b' q=2] l=[n=[p='c' q=3] l={[p='a' q=1]} r={}] r=~]
380655
381−`c` is a value of the same type of the values in `a`.
382−
383− > m
384− {[p='a' q=1] [p='b' q=2]}
385− > (~(put by m) 'c' 3)
386− {[p='a' q=1] [p='c' q=3] [p='b' q=2]}
387656 > (~(put by m) "zod" 26)
388− ! type-fail
657+ ! nest-fail
389658 ! exit
659+
390660 > (~(put by m) 'a' 2)
391− {[p='a' q=2] [p='b' q=2]}
661+ [n=[p='b' q=2] l=[n=[p='a' q=2] l={} r={}] r=~]
662+
663+ > (put:by m 'a' 2)
664+ {[p=[[98 2] [[97 1] 0 0] 0] q=[97 2]]}
392665
393−------------------------------------------------------------------------
394666
667+***
395668### `+-rep:by`
396669
397− +- rep :: replace by product
398− |* b/_|=({* *} +<+)
670+Replace by product
671+
672+Accumulate elements of map `a` using gate `b`, producing a noun.
673+
674+#### Accepts
675+
676+`a` is a map.
677+
678+`b` is a wet gate.
679+
680+#### Produces
681+
682+A noun.
683+
684+#### Source
685+
686+ +- rep
687+ |* b=_|=([* *] +<+)
399688 |-
400689 ?~ a +<+.b
401690 $(a r.a, +<+.b $(a l.a, +<+.b (b n.a +<+.b)))
402− ::
403691
404−Accumulate using gate from values in map
692+#### Examples
405693
406−XX interface changing.
694+ > =m (my [['a' 1] ['b' 2] ~])
695+ > (~(rep by m) |=(a=(pair * *) p.a))
696+ q=[97 1]
407697
408−------------------------------------------------------------------------
409698
699+***
410700### `+-rib:by`
411701
412− +- rib :: transform + product
413− |* {b/* c/gate}
702+Replace values with accumulator
703+
704+#### Accepts
705+
706+`a` is a map.
707+
708+`b` is a noun.
709+
710+`c` is a wet gate.
711+
712+####
713+
714+A cell of nouns.
715+
716+#### Source
717+
718+ +- rib
719+ |* [b=* c=gate]
414720 |- ^+ [b a]
415721 ?~ a [b ~]
416722 =+ d=(c n.a b)
@@ -418,77 +724,143 @@ XX interface changing.
418724 =+ e=$(a l.a, b -.d)
419725 =+ f=$(a r.a, b -.e)
420726 [-.f [n.a +.e +.f]]
421− ::
422727
423−Replace values with accumulator
728+#### Examples
424729
425−XX interface changing, possibly disappearing
730+ > =m (my [['a' 1] ['b' 2] ~])
731+ > (~(rib by m) [1 2] (con by m))
426732
427−------------------------------------------------------------------------
733+ > (~(rep by m) [1 2] |=(a=(pair * *) p.a))
428734
735+***
429736### `+-run:by`
430737
431738Transform values
432739
433− +- run :: apply gate to values
434− |* b/gate
435− |-
436− ?~ a a
437− [n=[p=p.n.a q=(b q.n.a)] l=$(a l.a) r=$(a r.a)]
740+Iterates over every value in map `a` using gate `b`, producing a map.
438741
439−Iterates over every value in set `a` using gate `b`. Produces a map.
742+#### Accepts
440743
441744`a` is a map.
442745
443746`b` is a wet gate.
444747
445− > m
446− {[p='a' q=1] [p='b' q=2]}
748+#### Produces
749+
750+A map.
751+
752+#### Source
753+
754+ +- run
755+ |* b=gate
756+ |-
757+ ?~ a a
758+ [n=[p=p.n.a q=(b q.n.a)] l=$(a l.a) r=$(a r.a)]
759+
760+#### Examples
761+
762+ > =m (my [['a' 1] ['b' 2] ~])
763+
447764 > ^+(m (~(run by m) dec))
448− {[p='a' q=0] [p='b' q=1]}
765+ [n=[p='b' q=1] l={[p='a' q=0]} r={}]
766+
449767 > `(map @tas @t)`(~(run by m) (cury scot %ux))
450768 {[p=%a q='0x1'] [p=%b q='0x2']}
451769
452−------------------------------------------------------------------------
453770
771+***
772+### `+-rut:by`
773+
774+Transform nodes
775+
776+Applies a gate `b` to nodes in map `a`.
777+
778+#### Accepts
779+
780+`a` is a map.
781+
782+`b` is a wet gate.
783+
784+#### Produces
785+
786+A map.
787+
788+#### Source
789+
790+ +- rut
791+ |* b=gate
792+ |-
793+ ?~ a a
794+ [n=[p=p.n.a q=(b p.n.a q.n.a)] l=$(a l.a) r=$(a r.a)]
795+
796+#### Examples
797+
798+ > =m (my [['a' 1] ['b' 2] ~])
799+
800+***
454801### `+-tap:by`
455802
456803Listify pairs
457804
458− +- tap :: listify pairs
459− ~/ %tap
460− |= b/(list _?>(?=(^ a) n.a))
461− ^+ b
462− ?~ a
463− b
464− $(a r.a, b [n.a $(a l.a)])
465− ::
805+Produces the list of all elements in map `a` that is prepended to list `b`,
806+which is empty by default.
466807
467−Produces the list of all elements in map `a` that is prepended to list
468−`b`, which is empty by default.
808+#### Accepts
469809
470810`a` is a map.
471811
472812`b` is a list.
473813
474− > m
475− {[p='a' q=1] [p='b' q=2]}
814+#### Produces
815+
816+A list.
817+
818+#### Source
819+
820+ +- tap
821+ =< $
822+ ~/ %tap
823+ =| b=(list _?>(?=(^ a) n.a))
824+ |. ^+ b
825+ ?~ a
826+ b
827+ $(a r.a, b [n.a $(a l.a)])
828+
829+#### Examples
830+
831+ > =m (my [['a' 1] ['b' 2] ~])
832+ [n=[p='b' q=2] l={[p='a' q=1]} r={}]
476833 > `*`m
477834 [[98 2] [[97 1] 0 0] 0]
478− > (~(tap by m))
835+
836+ > ~(tap by m)
479837 ~[[p='b' q=2] [p='a' q=1]]
480− > `*`(~(tap by m))
838+ > `*`~(tap by m)
481839 [[98 2] [97 1] 0]
482840
483−------------------------------------------------------------------------
484−
841+***
485842### `+-uni:by`
486843
487844Union
488845
489− +- uni :: union, merge
846+Produces a map of the union between the keys of `a` and `b`. If `b` shares a
847+key with `a`, the tuple from `b` is preserved.
848+
849+#### Accepts
850+
851+`a` is a map.
852+
853+`b` is a map.
854+
855+#### Produces
856+
857+A map.
858+
859+#### Source
860+
861+ +- uni
490862 ~/ %uni
491− |* b/_a
863+ |* b=_a
492864 |- ^+ a
493865 ?~ b
494866 a
@@ -506,83 +878,101 @@ Union
506878 $(b [n.b $(b l.b, a [n.a l.a ~]) r.b], a r.a)
507879 $(b [n.b l.b $(b r.b, a [n.a ~ r.a])], a l.a)
508880
509−Produces a map of the union between the keys of `a` and `b`. If `b`
510−shares a key with `a`, the tuple from `b` is preserved.
881+#### Examples
511882
512−`a` is a map.
883+ > =m (my [['a' 1] ['b' 2] ~])
513884
514−`b` is a map.
885+ > =o (my [['c' 3] ['d' 4] ~])
515886
516− > m
517− {[p='a' q=1] [p='b' q=2]}
518− > o
519− {[p='d' q=4] [p='c' q=3]}
520887 > (~(uni by m) o)
521− {[p='d' q=4] [p='a' q=1] [p='c' q=3] [p='b' q=2]}
888+ [n=[p='b' q=2] l=[n=[p='d' q=4] l={} r={[p='a' q=1] [p='c' q=3]}] r=~]
889+
522890 > (~(uni by m) ~)
523891 {[p='a' q=1] [p='b' q=2]}
892+
524893 > n
525894 {[p='a' q=1] [p='c' q=3]}
526895 > (~(uni by o) n)
527896 {[p='d' q=4] [p='a' q=1] [p='c' q=3]}
528897
529−------------------------------------------------------------------------
530898
899+***
531900### `+-urn:by`
532901
533902Turn (with key)
534903
535− +- urn :: apply gate to nodes
536− |* b/$-({* *} *)
537− |-
538− ?~ a ~
539− [n=[p=p.n.a q=(b p.n.a q.n.a)] l=$(a l.a) r=$(a r.a)]
540−
541904Iterates over every value in map `a` using gate `b`, which accepts both
542905the key and the value of each element as its sample.
543906
907+#### Accepts
908+
544909`a` is a map.
545910
546−`b` is a wet gate that accepts two nouns (a key and a value) and
547−produces a noun (the new value).
911+`b` is a wet gate that accepts two nouns.
912+
913+#### Produces
914+
915+A noun.
916+
917+#### Source
918+
919+ +- urn
920+ |* b=$-({* *} *)
921+ |-
922+ ?~ a ~
923+ [n=[p=p.n.a q=(b p.n.a q.n.a)] l=$(a l.a) r=$(a r.a)
924+
925+
926+#### Examples
548927
549928 > m
550929 {[p='a' q=1] [p='b' q=2]}
551930
552− > (~(urn by m) |=(a/(pair * *) q.a))
931+ > (~(urn by m) |=(a=(pair * *) q.a))
553932 {[p='a' q=1] [p='b' q=2]}
554933
555− > (~(urn by m) |=(a/(pair * *) 7))
934+ > (~(urn by m) |=(a=(pair * *) 7))
556935 {[p='a' q=7] [p='b' q=7]}
557936
558− > (~(urn by m) |=(a/(pair * *) p.a))
937+ > (~(urn by m) |=(a=(pair * *) p.a))
559938 {[p='a' q=97] [p='b' q=98]}
560939
561−------------------------------------------------------------------------
940+***
562941
563942### `+-wyt:by`
564943
565944Depth
566945
567− +- wyt :: depth of map
946+Produce the depth of the tree map `a`.
947+
948+#### Accepts
949+
950+`a` is a map.
951+
952+#### Produces
953+
954+An atom.
955+
956+#### Source
957+
958+ +- wyt
568959 |- ^- @
569960 ?~(a 0 +((add $(a l.a) $(a r.a))))
570961
571−Produce the depth of the tree map `a`.
962+#### Examples
572963
573−`a` is a map.
964+ > =m (my [['a' 1] ['b' 2] ~])
965+
966+ > =o (my [['c' 3] ['d' 4] ~])
574967
575− > m
576− {[p='a' q=1] [p='b' q=2]}
577− > o
578− {[p='d' q=4] [p='c' q=3]}
579968 > ~(wyt by m)
580969 2
970+
581971 > ~(wyt by o)
582972 2
973+
583974 > ~(wyt by (~(uni by m) o))
584975 4
585976
586977
587−
588978***