10Container arm for map operation arms. A map is a set of key-value pairs. The
11contained arms inherit its sample map, `a`.
23 =* node ?>(?=(^ a) n.a)
29 > ~(. by (my [%a 1] [%b 2] ~))
33 { n/{?(p/$a p/$b) q/@ud}
34 l/nlr({p/?($b $a) q/@ud})
35 r/nlr({p/?($b $a) q/@ud})
39 <119.wim 31.ohr 1.jmk $143>
48Computes the logical AND on the results of slamming every element in map `a`
70 ?&((b q.n.a) $(a l.a) $(a r.a))
76 > =b (my [['a' 1] ['b' [2 3]] ~])
77 > (~(all by b) |=(a=* ?@(a & |)))
80 > =a (my [['a' 1] ['b' 2] ['c' 3] ['d' 4] ['e' 5] ~])
81 > (~(all by a) |=(a=@ (lte a 6)))
84 > (~(all by a) |=(a=@ (lte a 4)))
93Computes the logical OR on the results of slamming every element with
115 ?|((b q.n.a) $(a l.a) $(a r.a))
121 > =b (my [['a' 1] ['b' [2 3]] ~])
122 > (~(any by b) |=(a=* ?@(a & |)))
125 > =a (my [['a' 1] ['b' 2] ['c' 3] ['d' 4] ['e' 5] ~])
126 > (~(any by a) |=(a=@ (lte a 4)))
135Computes whether `a` has a correct horizontal order and a correct vertical
136order, producing a flag.
150 =| [l=(unit) r=(unit)]
153 ?& ?~(l & (gor p.n.a u.l))
154 ?~(r & (gor u.r p.n.a))
155 ?~(l.a & ?&((vor p.n.a p.n.l.a) $(a l.a, l `p.n.a)))
156 ?~(r.a & ?&((vor p.n.a p.n.r.a) $(a r.a, r `p.n.a)))
163 > =a (my [['a' 1] ['b' [2 3]] ~])
167 > =s (my [[1 2] [3 4] ~])
168 > =z ?~ s ~ s(p.n 10)
170 [n=[p=10 q=2] l={} r={[p=3 q=4]}]
178See section [`2f`](@/docs/reference/library/2f.md) for more information on noun ordering.
184Splits map `a` into two maps `l` and `r`, with the head at `b` discarded.
216 [n.d l.d [n.a r.d r.a]]
219 [n.d [n.a l.a l.d] r.d]
225 > =a (my [['a' 1] ['b' 2] ['c' 3] ~])
227 > (~(bif by a) ['b' 2])
228 [l=[n=[p='c' q=3] l=[n=[p='a' q=1] l={} r={}] r=~] r=~]
250 ^- (map _p:node (pair (unit _q:node) (unit _q:node)))
278 =+ c=~(tap by (def b))
279 =+ [d e]=[`_a`~ `_a`~]
284 d ?~(q.q.i.c d (~(put by d) p.i.c u.q.q.i.c))
285 e ?~(p.q.i.c e (~(put by e) p.i.c u.p.q.i.c))
298Produces map `a` with the element located at key `b` removed.
304`b` is a key as a noun.
326 ?: (vor p.n.l.a p.n.r.a)
327 [n.l.a l.l.a $(l.a r.l.a)]
328 [n.r.a $(r.a l.r.a) r.r.a]
334 > =b (my [['a' 1] ['b' [2 3]] ~])
336 [n=[p='b' q=[2 3]] l=~ r=~]
344Produce the address of key `b` within map `a`.
350`b` is a key as a noun.
364 ?: =(b p.n.a) [~ u=(peg c 2)]
366 $(a l.a, c (peg c 6))
367 $(a r.a, c (peg c 7))
373 > =b (my [['a' 1] ['b' [2 3]] ~])
383Insert a list of key-value pairs `b` into map `a`.
389`b` is a list of cells of key-value nouns `p` and `q`.
400 |* b=(list [p=* q=*])
401 => .(b `(list _?>(?=(^ a) n.a))`b)
405 $(b t.b, a (put p.i.b q.i.b))
411 > =a (my [['a' 1] ['b' 2] ~])
412 > =b [['c' 3] ['d' 4] ~]
415 [n=[p='b' q=2] l=[n=[p='d' q=4] l={} r={[p='a' q=1] [p='c' q=3]}] r=~]
423Produce the unit value of the value located at key `b` within map `a`.
429`b` is a key as a noun.
441 ^- [$@(~ [~ u=_?>(?=(^ a) q.n.a)])]
455 > =b (my [['a' 1] ['b' [2 3]] ~])
460 > =m (my [['a' 1] ['b' 2] ~])
470Produce the value located at key `b` within map `a`. Crash if key `b` does not
477`b` is a key as a noun.
494 > =m (my [['a' 1] ['b' 2] ~])
496 [n=[p='b' q=2] l={[p='a' q=1]} r={}]
510Checks whether map `a` contains an element with key `b`, producing a flag.
516`b` is a key as a noun.
534 > =b (my [['a' 1] ['b' [2 3]] ~])
547Produces a map of the (key) intersection between two maps of the same type, `a`
548and `b`. If both maps have an identical key that point to different values, the
549element from map `b` is used.
574 [n.b $(a l.a, b l.b) $(a r.a, b r.b)]
576 %- uni(a $(a l.a, b [n.b l.b ~])) $(b r.b)
577 %- uni(a $(a r.a, b [n.b ~ r.b])) $(b l.b)
579 [n.b $(b l.b, a l.a) $(b r.b, a r.a)]
581 %- uni(a $(b l.b, a [n.a l.a ~])) $(a r.a)
582 %- uni(a $(b r.b, a [n.a ~ r.a])) $(a l.a)
588 > =n (my [['a' 1] ['c' 3] ~])
589 > =m (my [['a' 1] ['b' 2] ~])
592 [n=[p='a' q=1] l=~ r=~]
594 > =p (my [['a' 2] ['b' 2] ~])
596 [n=[p='b' q=2] l={[p='a' q=2]} r={}]
598 [n=[p='a' q=1] l=~ r=~]
600 > =q (my [['a' 2] ['c' 2] ~])
602 [n=[p='c' q=2] l={[p='a' q=2]} r={}]
604 [n=[p='a' q=2] l=~ r=~]
606 > =o (my [['c' 3] ['d' 4] ~])
616Produces map `a` with the addition of a key-value pair, where the value is a
619Accept a noun and a unit of a noun of the type of the map's keys and values,
620respectively. Validate that the value is not null and put the pair in the map.
621If the value is null, delete the key.
637 |* [b=_?>(?=(^ a) p.n.a) c=(unit ,_?>(?=(^ a) q.n.a))]
646 > =m (my [['a' 1] ['b' 2] ~])
647 > (~(mar by m) 'c' (some 3))
648 [n=[p='b' q=2] l=[n=[p='c' q=3] l=[n=[p='a' q=1] l={} r={}] r=~] r=~]
650 > (~(mar by m) 'c' ~)
651 [n=[p='b' q=2] l=[n=[p='a' q=1] l=~ r=~] r=~]
653 > (~(mar by m) 'b' ~)
654 [n=[p='a' q=1] l=~ r=~]
662Produces `a` with the addition of the key-value pair of `b` and `c`.
668`b` is a key of the same type as the keys in `a`.
670`c` is a value of the same type of the values in `a`.
694 [n.d l.d [n.a r.d r.a]]
699 [n.d [n.a l.a l.d] r.d]
705 > =m (my [['a' 1] ['b' 2] ~])
706 > (~(put by ~) 'c' 3)
707 [n=[p='b' q=2] l=[n=[p='c' q=3] l={[p='a' q=1]} r={}] r=~]
709 > (~(put by m) "zod" 26)
713 > (~(put by m) 'a' 2)
714 [n=[p='b' q=2] l=[n=[p='a' q=2] l={} r={}] r=~]
717 {[p=[[98 2] [[97 1] 0 0] 0] q=[97 2]]}
725Accumulate elements of map `a` using gate `b`, producing a noun.
744 $(a r.a, +<+.b $(a l.a, +<+.b (b n.a +<+.b)))
750 > =m (my [['a' 1] ['b' 2] ~])
751 > (~(rep by m) |=(a=(pair * *) p.a))
758Replace values with accumulator
789 > =m (my [['a' 1] ['b' 2] ~])
790 > (~(rib by m) [1 2] (con by m))
792 > (~(rep by m) [1 2] |=(a=(pair * *) p.a))
800Iterates over every value in map `a` using gate `b`, producing a map.
819 [n=[p=p.n.a q=(b q.n.a)] l=$(a l.a) r=$(a r.a)]
825 > =m (my [['a' 1] ['b' 2] ~])
827 > ^+(m (~(run by m) dec))
828 [n=[p='b' q=1] l={[p='a' q=0]} r={}]
830 > `(map @tas @t)`(~(run by m) (cury scot %ux))
831 {[p=%a q='0x1'] [p=%b q='0x2']}
839Applies a gate `b` to nodes in map `a`.
858 [n=[p=p.n.a q=(b p.n.a q.n.a)] l=$(a l.a) r=$(a r.a)]
864 > =m (my [['a' 1] ['b' 2] ~])
872Produces the list of all elements in map `a` that is prepended to list `b`,
873which is empty by default.
891 =| b=(list _?>(?=(^ a) n.a))
895 $(a r.a, b [n.a $(a l.a)])
901 > =m (my [['a' 1] ['b' 2] ~])
902 [n=[p='b' q=2] l={[p='a' q=1]} r={}]
904 [[98 2] [[97 1] 0 0] 0]
907 ~[[p='b' q=2] [p='a' q=1]]
917Produces a map of the union between the keys of `a` and `b`. If `b` shares a
918key with `a`, the tuple from `b` is preserved.
943 [n.b $(a l.a, b l.b) $(a r.a, b r.b)]
945 $(a [n.a $(a l.a, b [n.b l.b ~]) r.a], b r.b)
946 $(a [n.a l.a $(a r.a, b [n.b ~ r.b])], b l.b)
948 [n.b $(b l.b, a l.a) $(b r.b, a r.a)]
950 $(b [n.b $(b l.b, a [n.a l.a ~]) r.b], a r.a)
951 $(b [n.b l.b $(b r.b, a [n.a ~ r.a])], a l.a)
957 > =m (my [['a' 1] ['b' 2] ~])
959 > =o (my [['c' 3] ['d' 4] ~])
962 [n=[p='b' q=2] l=[n=[p='d' q=4] l={} r={[p='a' q=1] [p='c' q=3]}] r=~]
965 {[p='a' q=1] [p='b' q=2]}
968 {[p='a' q=1] [p='c' q=3]}
970 {[p='d' q=4] [p='a' q=1] [p='c' q=3]}
978Iterates over every value in map `a` using gate `b`, which accepts both
979the key and the value of each element as its sample.
985`b` is a wet gate that accepts two nouns.
998 [n=[p=p.n.a q=(b p.n.a q.n.a)] l=$(a l.a) r=$(a r.a)
1005 {[p='a' q=1] [p='b' q=2]}
1007 > (~(urn by m) |=(a=(pair * *) q.a))
1008 {[p='a' q=1] [p='b' q=2]}
1010 > (~(urn by m) |=(a=(pair * *) 7))
1011 {[p='a' q=7] [p='b' q=7]}
1013 > (~(urn by m) |=(a=(pair * *) p.a))
1014 {[p='a' q=97] [p='b' q=98]}
1023Produce the depth of the tree map `a`.
1038 ?~(a 0 +((add $(a l.a) $(a r.a))))
1044 > =m (my [['a' 1] ['b' 2] ~])
1046 > =o (my [['c' 3] ['d' 4] ~])
1054 > ~(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