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/hoon/reference/stdlib/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=~]
253 =+ c=~(tap by (def b))
254 =+ [d e]=[`_a`~ `_a`~]
259 d ?~(q.q.i.c d (~(put by d) p.i.c u.q.q.i.c))
260 e ?~(p.q.i.c e (~(put by e) p.i.c u.p.q.i.c))
273Produces map `a` with the element located at key `b` removed.
279`b` is a key as a noun.
301 ?: (vor p.n.l.a p.n.r.a)
302 [n.l.a l.l.a $(l.a r.l.a)]
303 [n.r.a $(r.a l.r.a) r.r.a]
309 > =b (my [['a' 1] ['b' [2 3]] ~])
311 [n=[p='b' q=[2 3]] l=~ r=~]
319Produce the address of key `b` within map `a`.
325`b` is a key as a noun.
339 ?: =(b p.n.a) [~ u=(peg c 2)]
341 $(a l.a, c (peg c 6))
342 $(a r.a, c (peg c 7))
348 > =b (my [['a' 1] ['b' [2 3]] ~])
358Insert a list of key-value pairs `b` into map `a`.
364`b` is a list of cells of key-value nouns `p` and `q`.
375 |* b=(list [p=* q=*])
376 => .(b `(list _?>(?=(^ a) n.a))`b)
380 $(b t.b, a (put p.i.b q.i.b))
386 > =a (my [['a' 1] ['b' 2] ~])
387 > =b [['c' 3] ['d' 4] ~]
390 [n=[p='b' q=2] l=[n=[p='d' q=4] l={} r={[p='a' q=1] [p='c' q=3]}] r=~]
398Produce the unit value of the value located at key `b` within map `a`.
404`b` is a key as a noun.
416 ^- [$@(~ [~ u=_?>(?=(^ a) q.n.a)])]
430 > =b (my [['a' 1] ['b' [2 3]] ~])
435 > =m (my [['a' 1] ['b' 2] ~])
445Produce the value located at key `b` within map `a`. Crash if key `b` does not
452`b` is a key as a noun.
469 > =m (my [['a' 1] ['b' 2] ~])
471 [n=[p='b' q=2] l={[p='a' q=1]} r={}]
483Grab value with default
485Produce the value located at key `b` within map `a`. Use default value `c` if
492`b` is a key as a noun.
503 ++ gut :: fall value by key
512 > =m (my [['a' 1] ['b' 2] ~])
514 [n=[p='b' q=2] l={[p='a' q=1]} r={}]
516 > (~(gut by m) 'a' 0)
519 > (~(gut by m) 'c' 0)
528Checks whether map `a` contains an element with key `b`, producing a flag.
534`b` is a key as a noun.
552 > =b (my [['a' 1] ['b' [2 3]] ~])
565Produces a map of the (key) intersection between two maps of the same type, `a`
566and `b`. If both maps have an identical key that point to different values, the
567element from map `b` is used.
592 [n.b $(a l.a, b l.b) $(a r.a, b r.b)]
594 %- uni(a $(a l.a, b [n.b l.b ~])) $(b r.b)
595 %- uni(a $(a r.a, b [n.b ~ r.b])) $(b l.b)
597 [n.b $(b l.b, a l.a) $(b r.b, a r.a)]
599 %- uni(a $(b l.b, a [n.a l.a ~])) $(a r.a)
600 %- uni(a $(b r.b, a [n.a ~ r.a])) $(a l.a)
606 > =n (my [['a' 1] ['c' 3] ~])
607 > =m (my [['a' 1] ['b' 2] ~])
610 [n=[p='a' q=1] l=~ r=~]
612 > =p (my [['a' 2] ['b' 2] ~])
614 [n=[p='b' q=2] l={[p='a' q=2]} r={}]
616 [n=[p='a' q=1] l=~ r=~]
618 > =q (my [['a' 2] ['c' 2] ~])
620 [n=[p='c' q=2] l={[p='a' q=2]} r={}]
622 [n=[p='a' q=2] l=~ r=~]
624 > =o (my [['c' 3] ['d' 4] ~])
635Produces a set of all keys in map `a` that is prepended to set `b`,
636which is empty by default.
652 =+ b=`(set _?>(?=(^ a) p.n.a))`~
655 $(a r.a, b $(a l.a, b (~(put in b) p.n.a)))
661 > =m (my [['a' 1] ['b' 2] ~])
662 [n=[p='b' q=2] l={[p='a' q=1]} r={}]
674Produces map `a` with the addition of a key-value pair, where the value is a
677Accept a noun and a unit of a noun of the type of the map's keys and values,
678respectively. Validate that the value is not null and put the pair in the map.
679If the value is null, delete the key.
695 |* [b=_?>(?=(^ a) p.n.a) c=(unit ,_?>(?=(^ a) q.n.a))]
704 > =m (my [['a' 1] ['b' 2] ~])
705 > (~(mar by m) 'c' (some 3))
706 [n=[p='b' q=2] l=[n=[p='c' q=3] l=[n=[p='a' q=1] l={} r={}] r=~] r=~]
708 > (~(mar by m) 'c' ~)
709 [n=[p='b' q=2] l=[n=[p='a' q=1] l=~ r=~] r=~]
711 > (~(mar by m) 'b' ~)
712 [n=[p='a' q=1] l=~ r=~]
720Produces `a` with the addition of the key-value pair of `b` and `c`.
726`b` is a key of the same type as the keys in `a`.
728`c` is a value of the same type of the values in `a`.
752 [n.d l.d [n.a r.d r.a]]
757 [n.d [n.a l.a l.d] r.d]
763 > =m (my [['a' 1] ['b' 2] ~])
764 > (~(put by ~) 'c' 3)
765 [n=[p='b' q=2] l=[n=[p='c' q=3] l={[p='a' q=1]} r={}] r=~]
767 > (~(put by m) "zod" 26)
771 > (~(put by m) 'a' 2)
772 [n=[p='b' q=2] l=[n=[p='a' q=2] l={} r={}] r=~]
775 {[p=[[98 2] [[97 1] 0 0] 0] q=[97 2]]}
783Accumulate elements of map `a` using gate `b`, producing a noun.
802 $(a r.a, +<+.b $(a l.a, +<+.b (b n.a +<+.b)))
808 > =m (my [['a' 1] ['b' 2] ~])
809 > (~(rep by m) |=(a=(pair * *) p.a))
816Replace values with accumulator
847 > =m (my [['a' 1] ['b' 2] ~])
848 > (~(rib by m) [1 2] (con by m))
850 > (~(rep by m) [1 2] |=(a=(pair * *) p.a))
858Iterates over every value in map `a` using gate `b`, producing a map.
877 [n=[p=p.n.a q=(b q.n.a)] l=$(a l.a) r=$(a r.a)]
883 > =m (my [['a' 1] ['b' 2] ~])
885 > ^+(m (~(run by m) dec))
886 [n=[p='b' q=1] l={[p='a' q=0]} r={}]
888 > `(map @tas @t)`(~(run by m) (cury scot %ux))
889 {[p=%a q='0x1'] [p=%b q='0x2']}
897Applies a gate `b` to nodes in map `a`.
916 [n=[p=p.n.a q=(b p.n.a q.n.a)] l=$(a l.a) r=$(a r.a)]
922 > =m (my [['a' 1] ['b' 2] ~])
930Produces the list of all elements in map `a` that is prepended to list `b`,
931which is empty by default.
949 =| b=(list _?>(?=(^ a) n.a))
953 $(a r.a, b [n.a $(a l.a)])
959 > =m (my [['a' 1] ['b' 2] ~])
960 [n=[p='b' q=2] l={[p='a' q=1]} r={}]
962 [[98 2] [[97 1] 0 0] 0]
965 ~[[p='b' q=2] [p='a' q=1]]
975Produces a map of the union between the keys of `a` and `b`. If `b` shares a
976key with `a`, the tuple from `b` is preserved.
1001 [n.b $(a l.a, b l.b) $(a r.a, b r.b)]
1002 ?: (gor p.n.b p.n.a)
1003 $(a [n.a $(a l.a, b [n.b l.b ~]) r.a], b r.b)
1004 $(a [n.a l.a $(a r.a, b [n.b ~ r.b])], b l.b)
1006 [n.b $(b l.b, a l.a) $(b r.b, a r.a)]
1007 ?: (gor p.n.a p.n.b)
1008 $(b [n.b $(b l.b, a [n.a l.a ~]) r.b], a r.a)
1009 $(b [n.b l.b $(b r.b, a [n.a ~ r.a])], a l.a)
1015 > =m (my [['a' 1] ['b' 2] ~])
1017 > =o (my [['c' 3] ['d' 4] ~])
1020 [n=[p='b' q=2] l=[n=[p='d' q=4] l={} r={[p='a' q=1] [p='c' q=3]}] r=~]
1023 {[p='a' q=1] [p='b' q=2]}
1026 {[p='a' q=1] [p='c' q=3]}
1028 {[p='d' q=4] [p='a' q=1] [p='c' q=3]}
1036Iterates over every value in map `a` using gate `b`, which accepts both
1037the key and the value of each element as its sample.
1043`b` is a wet gate that accepts two nouns.
1056 [n=[p=p.n.a q=(b p.n.a q.n.a)] l=$(a l.a) r=$(a r.a)
1063 {[p='a' q=1] [p='b' q=2]}
1065 > (~(urn by m) |=(a=(pair * *) q.a))
1066 {[p='a' q=1] [p='b' q=2]}
1068 > (~(urn by m) |=(a=(pair * *) 7))
1069 {[p='a' q=7] [p='b' q=7]}
1071 > (~(urn by m) |=(a=(pair * *) p.a))
1072 {[p='a' q=97] [p='b' q=98]}
1081Produce the depth of the tree map `a`.
1096 ?~(a 0 +((add $(a l.a) $(a r.a))))
1102 > =m (my [['a' 1] ['b' 2] ~])
1104 > =o (my [['c' 3] ['d' 4] ~])
1112 > ~(wyt by (~(uni by m) o))
1122Produces a list of all values in map `a` that is prepended to list `b`,
1123which is empty by default.
1139 =+ b=`(list _?>(?=(^ a) q.n.a))`~
1142 $(a r.a, b [q.n.a $(a l.a)])
1148 > =m (my [['a' 1] ['b' 2] ~])
1149 [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