11Container arm for map operation arms. A map is a set of key-value pairs. The
12contained arms inherit its sample map, `a`.
24 =* node ?>(?=(^ a) n.a)
30 > ~(. by (my [%a 1] [%b 2] ~))
34 { n/{?(p/$a p/$b) q/@ud}
35 l/nlr({p/?($b $a) q/@ud})
36 r/nlr({p/?($b $a) q/@ud})
40 <119.wim 31.ohr 1.jmk $143>
49Computes the logical AND on the results of slamming every element in map `a`
71 ?&((b q.n.a) $(a l.a) $(a r.a))
77 > =b (my [['a' 1] ['b' [2 3]] ~])
78 > (~(all by b) |=(a=* ?@(a & |)))
81 > =a (my [['a' 1] ['b' 2] ['c' 3] ['d' 4] ['e' 5] ~])
82 > (~(all by a) |=(a=@ (lte a 6)))
85 > (~(all by a) |=(a=@ (lte a 4)))
94Computes the logical OR on the results of slamming every element with
116 ?|((b q.n.a) $(a l.a) $(a r.a))
122 > =b (my [['a' 1] ['b' [2 3]] ~])
123 > (~(any by b) |=(a=* ?@(a & |)))
126 > =a (my [['a' 1] ['b' 2] ['c' 3] ['d' 4] ['e' 5] ~])
127 > (~(any by a) |=(a=@ (lte a 4)))
136Computes whether `a` has a correct horizontal order and a correct vertical
137order, producing a flag.
151 =| [l=(unit) r=(unit)]
154 ?& ?~(l & (gor p.n.a u.l))
155 ?~(r & (gor u.r p.n.a))
156 ?~(l.a & ?&((vor p.n.a p.n.l.a) $(a l.a, l `p.n.a)))
157 ?~(r.a & ?&((vor p.n.a p.n.r.a) $(a r.a, r `p.n.a)))
164 > =a (my [['a' 1] ['b' [2 3]] ~])
168 > =s (my [[1 2] [3 4] ~])
169 > =z ?~ s ~ s(p.n 10)
171 [n=[p=10 q=2] l={} r={[p=3 q=4]}]
179See section [`2f`](@/docs/reference/library/2f.md) for more information on noun ordering.
185Splits map `a` into two maps `l` and `r`, with the head at `b` discarded.
217 [n.d l.d [n.a r.d r.a]]
220 [n.d [n.a l.a l.d] r.d]
226 > =a (my [['a' 1] ['b' 2] ['c' 3] ~])
228 > (~(bif by a) ['b' 2])
229 [l=[n=[p='c' q=3] l=[n=[p='a' q=1] l={} r={}] r=~] r=~]
251 ^- (map _p:node (pair (unit _q:node) (unit _q:node)))
279 =+ c=~(tap by (def b))
280 =+ [d e]=[`_a`~ `_a`~]
285 d ?~(q.q.i.c d (~(put by d) p.i.c u.q.q.i.c))
286 e ?~(p.q.i.c e (~(put by e) p.i.c u.p.q.i.c))
299Produces map `a` with the element located at key `b` removed.
305`b` is a key as a noun.
327 ?: (vor p.n.l.a p.n.r.a)
328 [n.l.a l.l.a $(l.a r.l.a)]
329 [n.r.a $(r.a l.r.a) r.r.a]
335 > =b (my [['a' 1] ['b' [2 3]] ~])
337 [n=[p='b' q=[2 3]] l=~ r=~]
345Produce the address of key `b` within map `a`.
351`b` is a key as a noun.
365 ?: =(b p.n.a) [~ u=(peg c 2)]
367 $(a l.a, c (peg c 6))
368 $(a r.a, c (peg c 7))
374 > =b (my [['a' 1] ['b' [2 3]] ~])
384Insert a list of key-value pairs `b` into map `a`.
390`b` is a list of cells of key-value nouns `p` and `q`.
401 |* b=(list [p=* q=*])
402 => .(b `(list _?>(?=(^ a) n.a))`b)
406 $(b t.b, a (put p.i.b q.i.b))
412 > =a (my [['a' 1] ['b' 2] ~])
413 > =b [['c' 3] ['d' 4] ~]
416 [n=[p='b' q=2] l=[n=[p='d' q=4] l={} r={[p='a' q=1] [p='c' q=3]}] r=~]
424Produce the unit value of the value located at key `b` within map `a`.
430`b` is a key as a noun.
442 ^- [$@(~ [~ u=_?>(?=(^ a) q.n.a)])]
456 > =b (my [['a' 1] ['b' [2 3]] ~])
461 > =m (my [['a' 1] ['b' 2] ~])
471Produce the value located at key `b` within map `a`. Crash if key `b` does not
478`b` is a key as a noun.
495 > =m (my [['a' 1] ['b' 2] ~])
497 [n=[p='b' q=2] l={[p='a' q=1]} r={}]
511Checks whether map `a` contains an element with key `b`, producing a flag.
517`b` is a key as a noun.
535 > =b (my [['a' 1] ['b' [2 3]] ~])
548Produces a map of the (key) intersection between two maps of the same type, `a`
549and `b`. If both maps have an identical key that point to different values, the
550element from map `b` is used.
575 [n.b $(a l.a, b l.b) $(a r.a, b r.b)]
577 %- uni(a $(a l.a, b [n.b l.b ~])) $(b r.b)
578 %- uni(a $(a r.a, b [n.b ~ r.b])) $(b l.b)
580 [n.b $(b l.b, a l.a) $(b r.b, a r.a)]
582 %- uni(a $(b l.b, a [n.a l.a ~])) $(a r.a)
583 %- uni(a $(b r.b, a [n.a ~ r.a])) $(a l.a)
589 > =n (my [['a' 1] ['c' 3] ~])
590 > =m (my [['a' 1] ['b' 2] ~])
593 [n=[p='a' q=1] l=~ r=~]
595 > =p (my [['a' 2] ['b' 2] ~])
597 [n=[p='b' q=2] l={[p='a' q=2]} r={}]
599 [n=[p='a' q=1] l=~ r=~]
601 > =q (my [['a' 2] ['c' 2] ~])
603 [n=[p='c' q=2] l={[p='a' q=2]} r={}]
605 [n=[p='a' q=2] l=~ r=~]
607 > =o (my [['c' 3] ['d' 4] ~])
618Produces a set of all keys in map `a` that is prepended to set `b`,
619which is empty by default.
635 =+ b=`(set _?>(?=(^ a) p.n.a))`~
638 $(a r.a, b $(a l.a, b (~(put in b) p.n.a)))
644 > =m (my [['a' 1] ['b' 2] ~])
645 [n=[p='b' q=2] l={[p='a' q=1]} r={}]
657Produces map `a` with the addition of a key-value pair, where the value is a
660Accept a noun and a unit of a noun of the type of the map's keys and values,
661respectively. Validate that the value is not null and put the pair in the map.
662If the value is null, delete the key.
678 |* [b=_?>(?=(^ a) p.n.a) c=(unit ,_?>(?=(^ a) q.n.a))]
687 > =m (my [['a' 1] ['b' 2] ~])
688 > (~(mar by m) 'c' (some 3))
689 [n=[p='b' q=2] l=[n=[p='c' q=3] l=[n=[p='a' q=1] l={} r={}] r=~] r=~]
691 > (~(mar by m) 'c' ~)
692 [n=[p='b' q=2] l=[n=[p='a' q=1] l=~ r=~] r=~]
694 > (~(mar by m) 'b' ~)
695 [n=[p='a' q=1] l=~ r=~]
703Produces `a` with the addition of the key-value pair of `b` and `c`.
709`b` is a key of the same type as the keys in `a`.
711`c` is a value of the same type of the values in `a`.
735 [n.d l.d [n.a r.d r.a]]
740 [n.d [n.a l.a l.d] r.d]
746 > =m (my [['a' 1] ['b' 2] ~])
747 > (~(put by ~) 'c' 3)
748 [n=[p='b' q=2] l=[n=[p='c' q=3] l={[p='a' q=1]} r={}] r=~]
750 > (~(put by m) "zod" 26)
754 > (~(put by m) 'a' 2)
755 [n=[p='b' q=2] l=[n=[p='a' q=2] l={} r={}] r=~]
758 {[p=[[98 2] [[97 1] 0 0] 0] q=[97 2]]}
766Accumulate elements of map `a` using gate `b`, producing a noun.
785 $(a r.a, +<+.b $(a l.a, +<+.b (b n.a +<+.b)))
791 > =m (my [['a' 1] ['b' 2] ~])
792 > (~(rep by m) |=(a=(pair * *) p.a))
799Replace values with accumulator
830 > =m (my [['a' 1] ['b' 2] ~])
831 > (~(rib by m) [1 2] (con by m))
833 > (~(rep by m) [1 2] |=(a=(pair * *) p.a))
841Iterates over every value in map `a` using gate `b`, producing a map.
860 [n=[p=p.n.a q=(b q.n.a)] l=$(a l.a) r=$(a r.a)]
866 > =m (my [['a' 1] ['b' 2] ~])
868 > ^+(m (~(run by m) dec))
869 [n=[p='b' q=1] l={[p='a' q=0]} r={}]
871 > `(map @tas @t)`(~(run by m) (cury scot %ux))
872 {[p=%a q='0x1'] [p=%b q='0x2']}
880Applies a gate `b` to nodes in map `a`.
899 [n=[p=p.n.a q=(b p.n.a q.n.a)] l=$(a l.a) r=$(a r.a)]
905 > =m (my [['a' 1] ['b' 2] ~])
913Produces the list of all elements in map `a` that is prepended to list `b`,
914which is empty by default.
932 =| b=(list _?>(?=(^ a) n.a))
936 $(a r.a, b [n.a $(a l.a)])
942 > =m (my [['a' 1] ['b' 2] ~])
943 [n=[p='b' q=2] l={[p='a' q=1]} r={}]
945 [[98 2] [[97 1] 0 0] 0]
948 ~[[p='b' q=2] [p='a' q=1]]
958Produces a map of the union between the keys of `a` and `b`. If `b` shares a
959key with `a`, the tuple from `b` is preserved.
984 [n.b $(a l.a, b l.b) $(a r.a, b r.b)]
986 $(a [n.a $(a l.a, b [n.b l.b ~]) r.a], b r.b)
987 $(a [n.a l.a $(a r.a, b [n.b ~ r.b])], b l.b)
989 [n.b $(b l.b, a l.a) $(b r.b, a r.a)]
991 $(b [n.b $(b l.b, a [n.a l.a ~]) r.b], a r.a)
992 $(b [n.b l.b $(b r.b, a [n.a ~ r.a])], a l.a)
998 > =m (my [['a' 1] ['b' 2] ~])
1000 > =o (my [['c' 3] ['d' 4] ~])
1003 [n=[p='b' q=2] l=[n=[p='d' q=4] l={} r={[p='a' q=1] [p='c' q=3]}] r=~]
1006 {[p='a' q=1] [p='b' q=2]}
1009 {[p='a' q=1] [p='c' q=3]}
1011 {[p='d' q=4] [p='a' q=1] [p='c' q=3]}
1019Iterates over every value in map `a` using gate `b`, which accepts both
1020the key and the value of each element as its sample.
1026`b` is a wet gate that accepts two nouns.
1039 [n=[p=p.n.a q=(b p.n.a q.n.a)] l=$(a l.a) r=$(a r.a)
1046 {[p='a' q=1] [p='b' q=2]}
1048 > (~(urn by m) |=(a=(pair * *) q.a))
1049 {[p='a' q=1] [p='b' q=2]}
1051 > (~(urn by m) |=(a=(pair * *) 7))
1052 {[p='a' q=7] [p='b' q=7]}
1054 > (~(urn by m) |=(a=(pair * *) p.a))
1055 {[p='a' q=97] [p='b' q=98]}
1064Produce the depth of the tree map `a`.
1079 ?~(a 0 +((add $(a l.a) $(a r.a))))
1085 > =m (my [['a' 1] ['b' 2] ~])
1087 > =o (my [['c' 3] ['d' 4] ~])
1095 > ~(wyt by (~(uni by m) o))
1105Produces a list of all values in map `a` that is prepended to list `b`,
1106which is empty by default.
1122 =+ b=`(list _?>(?=(^ a) q.n.a))`~
1125 $(a r.a, b [q.n.a $(a l.a)])
1131 > =m (my [['a' 1] ['b' 2] ~])
1132 [n=[p='b' q=2] l={[p='a' q=1]} r={}]
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