14Container arm for map operation arms. A map is a set of key-value pairs. The
15contained arms inherit its sample map, `a`.
27 =* node ?>(?=(^ a) n.a)
33 > ~(. by (my [%a 1] [%b 2] ~))
37 { n/{?(p/$a p/$b) q/@ud}
38 l/nlr({p/?($b $a) q/@ud})
39 r/nlr({p/?($b $a) q/@ud})
43 <119.wim 31.ohr 1.jmk $143>
52Computes the logical AND on the results of slamming every element in map `a`
74 ?&((b q.n.a) $(a l.a) $(a r.a))
80 > =b (my [['a' 1] ['b' [2 3]] ~])
81 > (~(all by b) |=(a=* ?@(a & |)))
84 > =a (my [['a' 1] ['b' 2] ['c' 3] ['d' 4] ['e' 5] ~])
85 > (~(all by a) |=(a=@ (lte a 6)))
88 > (~(all by a) |=(a=@ (lte a 4)))
97Computes the logical OR on the results of slamming every element with
119 ?|((b q.n.a) $(a l.a) $(a r.a))
125 > =b (my [['a' 1] ['b' [2 3]] ~])
126 > (~(any by b) |=(a=* ?@(a & |)))
129 > =a (my [['a' 1] ['b' 2] ['c' 3] ['d' 4] ['e' 5] ~])
130 > (~(any by a) |=(a=@ (lte a 4)))
139Computes whether `a` has a correct horizontal order and a correct vertical
140order, producing a flag.
154 =| [l=(unit) r=(unit)]
157 ?& ?~(l & (gor p.n.a u.l))
158 ?~(r & (gor u.r p.n.a))
159 ?~(l.a & ?&((vor p.n.a p.n.l.a) $(a l.a, l `p.n.a)))
160 ?~(r.a & ?&((vor p.n.a p.n.r.a) $(a r.a, r `p.n.a)))
167 > =a (my [['a' 1] ['b' [2 3]] ~])
171 > =s (my [[1 2] [3 4] ~])
172 > =z ?~ s ~ s(p.n 10)
174 [n=[p=10 q=2] l={} r={[p=3 q=4]}]
182See section [`2f`](../2f) for more information on noun ordering.
188Splits map `a` into two maps `l` and `r`, with the head at `b` discarded.
220 [n.d l.d [n.a r.d r.a]]
223 [n.d [n.a l.a l.d] r.d]
229 > =a (my [['a' 1] ['b' 2] ['c' 3] ~])
231 > (~(bif by a) ['b' 2])
232 [l=[n=[p='c' q=3] l=[n=[p='a' q=1] l={} r={}] r=~] r=~]
254 ^- (map _p:node (pair (unit _q:node) (unit _q:node)))
282 =+ c=~(tap by (def b))
283 =+ [d e]=[`_a`~ `_a`~]
288 d ?~(q.q.i.c d (~(put by d) p.i.c u.q.q.i.c))
289 e ?~(p.q.i.c e (~(put by e) p.i.c u.p.q.i.c))
302Produces map `a` with the element located at key `b` removed.
308`b` is a key as a noun.
330 ?: (vor p.n.l.a p.n.r.a)
331 [n.l.a l.l.a $(l.a r.l.a)]
332 [n.r.a $(r.a l.r.a) r.r.a]
338 > =b (my [['a' 1] ['b' [2 3]] ~])
340 [n=[p='b' q=[2 3]] l=~ r=~]
348Produce the address of key `b` within map `a`.
354`b` is a key as a noun.
368 ?: =(b p.n.a) [~ u=(peg c 2)]
370 $(a l.a, c (peg c 6))
371 $(a r.a, c (peg c 7))
377 > =b (my [['a' 1] ['b' [2 3]] ~])
387Insert a list of key-value pairs `b` into map `a`.
393`b` is a list of cells of key-value nouns `p` and `q`.
404 |* b=(list [p=* q=*])
405 => .(b `(list _?>(?=(^ a) n.a))`b)
409 $(b t.b, a (put p.i.b q.i.b))
415 > =a (my [['a' 1] ['b' 2] ~])
416 > =b [['c' 3] ['d' 4] ~]
419 [n=[p='b' q=2] l=[n=[p='d' q=4] l={} r={[p='a' q=1] [p='c' q=3]}] r=~]
427Produce the unit value of the value located at key `b` within map `a`.
433`b` is a key as a noun.
445 ^- [$@(~ [~ u=_?>(?=(^ a) q.n.a)])]
459 > =b (my [['a' 1] ['b' [2 3]] ~])
464 > =m (my [['a' 1] ['b' 2] ~])
474Produce the value located at key `b` within map `a`. Crash if key `b` does not
481`b` is a key as a noun.
498 > =m (my [['a' 1] ['b' 2] ~])
500 [n=[p='b' q=2] l={[p='a' q=1]} r={}]
514Checks whether map `a` contains an element with key `b`, producing a flag.
520`b` is a key as a noun.
538 > =b (my [['a' 1] ['b' [2 3]] ~])
551Produces a map of the (key) intersection between two maps of the same type, `a`
552and `b`. If both maps have an identical key that point to different values, the
553element from map `b` is used.
578 [n.b $(a l.a, b l.b) $(a r.a, b r.b)]
580 %- uni(a $(a l.a, b [n.b l.b ~])) $(b r.b)
581 %- uni(a $(a r.a, b [n.b ~ r.b])) $(b l.b)
583 [n.b $(b l.b, a l.a) $(b r.b, a r.a)]
585 %- uni(a $(b l.b, a [n.a l.a ~])) $(a r.a)
586 %- uni(a $(b r.b, a [n.a ~ r.a])) $(a l.a)
592 > =n (my [['a' 1] ['c' 3] ~])
593 > =m (my [['a' 1] ['b' 2] ~])
596 [n=[p='a' q=1] l=~ r=~]
598 > =p (my [['a' 2] ['b' 2] ~])
600 [n=[p='b' q=2] l={[p='a' q=2]} r={}]
602 [n=[p='a' q=1] l=~ r=~]
604 > =q (my [['a' 2] ['c' 2] ~])
606 [n=[p='c' q=2] l={[p='a' q=2]} r={}]
608 [n=[p='a' q=2] l=~ r=~]
610 > =o (my [['c' 3] ['d' 4] ~])
620Produces map `a` with the addition of a key-value pair, where the value is a
623Accept a noun and a unit of a noun of the type of the map's keys and values,
624respectively. Validate that the value is not null and put the pair in the map.
625If the value is null, delete the key.
641 |* [b=_?>(?=(^ a) p.n.a) c=(unit ,_?>(?=(^ a) q.n.a))]
650 > =m (my [['a' 1] ['b' 2] ~])
651 > (~(mar by m) 'c' (some 3))
652 [n=[p='b' q=2] l=[n=[p='c' q=3] l=[n=[p='a' q=1] l={} r={}] r=~] r=~]
654 > (~(mar by m) 'c' ~)
655 [n=[p='b' q=2] l=[n=[p='a' q=1] l=~ r=~] r=~]
657 > (~(mar by m) 'b' ~)
658 [n=[p='a' q=1] l=~ r=~]
666Produces `a` with the addition of the key-value pair of `b` and `c`.
672`b` is a key of the same type as the keys in `a`.
674`c` is a value of the same type of the values in `a`.
698 [n.d l.d [n.a r.d r.a]]
703 [n.d [n.a l.a l.d] r.d]
709 > =m (my [['a' 1] ['b' 2] ~])
710 > (~(put by ~) 'c' 3)
711 [n=[p='b' q=2] l=[n=[p='c' q=3] l={[p='a' q=1]} r={}] r=~]
713 > (~(put by m) "zod" 26)
717 > (~(put by m) 'a' 2)
718 [n=[p='b' q=2] l=[n=[p='a' q=2] l={} r={}] r=~]
721 {[p=[[98 2] [[97 1] 0 0] 0] q=[97 2]]}
729Accumulate elements of map `a` using gate `b`, producing a noun.
748 $(a r.a, +<+.b $(a l.a, +<+.b (b n.a +<+.b)))
754 > =m (my [['a' 1] ['b' 2] ~])
755 > (~(rep by m) |=(a=(pair * *) p.a))
762Replace values with accumulator
793 > =m (my [['a' 1] ['b' 2] ~])
794 > (~(rib by m) [1 2] (con by m))
796 > (~(rep by m) [1 2] |=(a=(pair * *) p.a))
804Iterates over every value in map `a` using gate `b`, producing a map.
823 [n=[p=p.n.a q=(b q.n.a)] l=$(a l.a) r=$(a r.a)]
829 > =m (my [['a' 1] ['b' 2] ~])
831 > ^+(m (~(run by m) dec))
832 [n=[p='b' q=1] l={[p='a' q=0]} r={}]
834 > `(map @tas @t)`(~(run by m) (cury scot %ux))
835 {[p=%a q='0x1'] [p=%b q='0x2']}
843Applies a gate `b` to nodes in map `a`.
862 [n=[p=p.n.a q=(b p.n.a q.n.a)] l=$(a l.a) r=$(a r.a)]
868 > =m (my [['a' 1] ['b' 2] ~])
876Produces the list of all elements in map `a` that is prepended to list `b`,
877which is empty by default.
895 =| b=(list _?>(?=(^ a) n.a))
899 $(a r.a, b [n.a $(a l.a)])
905 > =m (my [['a' 1] ['b' 2] ~])
906 [n=[p='b' q=2] l={[p='a' q=1]} r={}]
908 [[98 2] [[97 1] 0 0] 0]
911 ~[[p='b' q=2] [p='a' q=1]]
921Produces a map of the union between the keys of `a` and `b`. If `b` shares a
922key with `a`, the tuple from `b` is preserved.
947 [n.b $(a l.a, b l.b) $(a r.a, b r.b)]
949 $(a [n.a $(a l.a, b [n.b l.b ~]) r.a], b r.b)
950 $(a [n.a l.a $(a r.a, b [n.b ~ r.b])], b l.b)
952 [n.b $(b l.b, a l.a) $(b r.b, a r.a)]
954 $(b [n.b $(b l.b, a [n.a l.a ~]) r.b], a r.a)
955 $(b [n.b l.b $(b r.b, a [n.a ~ r.a])], a l.a)
961 > =m (my [['a' 1] ['b' 2] ~])
963 > =o (my [['c' 3] ['d' 4] ~])
966 [n=[p='b' q=2] l=[n=[p='d' q=4] l={} r={[p='a' q=1] [p='c' q=3]}] r=~]
969 {[p='a' q=1] [p='b' q=2]}
972 {[p='a' q=1] [p='c' q=3]}
974 {[p='d' q=4] [p='a' q=1] [p='c' q=3]}
982Iterates over every value in map `a` using gate `b`, which accepts both
983the key and the value of each element as its sample.
989`b` is a wet gate that accepts two nouns.
1002 [n=[p=p.n.a q=(b p.n.a q.n.a)] l=$(a l.a) r=$(a r.a)
1009 {[p='a' q=1] [p='b' q=2]}
1011 > (~(urn by m) |=(a=(pair * *) q.a))
1012 {[p='a' q=1] [p='b' q=2]}
1014 > (~(urn by m) |=(a=(pair * *) 7))
1015 {[p='a' q=7] [p='b' q=7]}
1017 > (~(urn by m) |=(a=(pair * *) p.a))
1018 {[p='a' q=97] [p='b' q=98]}
1027Produce the depth of the tree map `a`.
1042 ?~(a 0 +((add $(a l.a) $(a r.a))))
1048 > =m (my [['a' 1] ['b' 2] ~])
1050 > =o (my [['c' 3] ['d' 4] ~])
1058 > ~(wyt by (~(uni by m) o))
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