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=~]
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={}]
509Grab value with default
511Produce the value located at key `b` within map `a`. Use default value `c` if
518`b` is a key as a noun.
529 ++ gut :: fall value by key
538 > =m (my [['a' 1] ['b' 2] ~])
540 [n=[p='b' q=2] l={[p='a' q=1]} r={}]
542 > (~(gut by m) 'a' 0)
545 > (~(gut by m) 'c' 0)
554Checks whether map `a` contains an element with key `b`, producing a flag.
560`b` is a key as a noun.
578 > =b (my [['a' 1] ['b' [2 3]] ~])
591Produces a map of the (key) intersection between two maps of the same type, `a`
592and `b`. If both maps have an identical key that point to different values, the
593element from map `b` is used.
618 [n.b $(a l.a, b l.b) $(a r.a, b r.b)]
620 %- uni(a $(a l.a, b [n.b l.b ~])) $(b r.b)
621 %- uni(a $(a r.a, b [n.b ~ r.b])) $(b l.b)
623 [n.b $(b l.b, a l.a) $(b r.b, a r.a)]
625 %- uni(a $(b l.b, a [n.a l.a ~])) $(a r.a)
626 %- uni(a $(b r.b, a [n.a ~ r.a])) $(a l.a)
632 > =n (my [['a' 1] ['c' 3] ~])
633 > =m (my [['a' 1] ['b' 2] ~])
636 [n=[p='a' q=1] l=~ r=~]
638 > =p (my [['a' 2] ['b' 2] ~])
640 [n=[p='b' q=2] l={[p='a' q=2]} r={}]
642 [n=[p='a' q=1] l=~ r=~]
644 > =q (my [['a' 2] ['c' 2] ~])
646 [n=[p='c' q=2] l={[p='a' q=2]} r={}]
648 [n=[p='a' q=2] l=~ r=~]
650 > =o (my [['c' 3] ['d' 4] ~])
661Produces a set of all keys in map `a` that is prepended to set `b`,
662which is empty by default.
678 =+ b=`(set _?>(?=(^ a) p.n.a))`~
681 $(a r.a, b $(a l.a, b (~(put in b) p.n.a)))
687 > =m (my [['a' 1] ['b' 2] ~])
688 [n=[p='b' q=2] l={[p='a' q=1]} r={}]
700Produces map `a` with the addition of a key-value pair, where the value is a
703Accept a noun and a unit of a noun of the type of the map's keys and values,
704respectively. Validate that the value is not null and put the pair in the map.
705If the value is null, delete the key.
721 |* [b=_?>(?=(^ a) p.n.a) c=(unit ,_?>(?=(^ a) q.n.a))]
730 > =m (my [['a' 1] ['b' 2] ~])
731 > (~(mar by m) 'c' (some 3))
732 [n=[p='b' q=2] l=[n=[p='c' q=3] l=[n=[p='a' q=1] l={} r={}] r=~] r=~]
734 > (~(mar by m) 'c' ~)
735 [n=[p='b' q=2] l=[n=[p='a' q=1] l=~ r=~] r=~]
737 > (~(mar by m) 'b' ~)
738 [n=[p='a' q=1] l=~ r=~]
746Produces `a` with the addition of the key-value pair of `b` and `c`.
752`b` is a key of the same type as the keys in `a`.
754`c` is a value of the same type of the values in `a`.
778 [n.d l.d [n.a r.d r.a]]
783 [n.d [n.a l.a l.d] r.d]
789 > =m (my [['a' 1] ['b' 2] ~])
790 > (~(put by ~) 'c' 3)
791 [n=[p='b' q=2] l=[n=[p='c' q=3] l={[p='a' q=1]} r={}] r=~]
793 > (~(put by m) "zod" 26)
797 > (~(put by m) 'a' 2)
798 [n=[p='b' q=2] l=[n=[p='a' q=2] l={} r={}] r=~]
801 {[p=[[98 2] [[97 1] 0 0] 0] q=[97 2]]}
809Accumulate elements of map `a` using gate `b`, producing a noun.
828 $(a r.a, +<+.b $(a l.a, +<+.b (b n.a +<+.b)))
834 > =m (my [['a' 1] ['b' 2] ~])
835 > (~(rep by m) |=(a=(pair * *) p.a))
842Replace values with accumulator
873 > =m (my [['a' 1] ['b' 2] ~])
874 > (~(rib by m) [1 2] (con by m))
876 > (~(rep by m) [1 2] |=(a=(pair * *) p.a))
884Iterates over every value in map `a` using gate `b`, producing a map.
903 [n=[p=p.n.a q=(b q.n.a)] l=$(a l.a) r=$(a r.a)]
909 > =m (my [['a' 1] ['b' 2] ~])
911 > ^+(m (~(run by m) dec))
912 [n=[p='b' q=1] l={[p='a' q=0]} r={}]
914 > `(map @tas @t)`(~(run by m) (cury scot %ux))
915 {[p=%a q='0x1'] [p=%b q='0x2']}
923Applies a gate `b` to nodes in map `a`.
942 [n=[p=p.n.a q=(b p.n.a q.n.a)] l=$(a l.a) r=$(a r.a)]
948 > =m (my [['a' 1] ['b' 2] ~])
956Produces the list of all elements in map `a` that is prepended to list `b`,
957which is empty by default.
975 =| b=(list _?>(?=(^ a) n.a))
979 $(a r.a, b [n.a $(a l.a)])
985 > =m (my [['a' 1] ['b' 2] ~])
986 [n=[p='b' q=2] l={[p='a' q=1]} r={}]
988 [[98 2] [[97 1] 0 0] 0]
991 ~[[p='b' q=2] [p='a' q=1]]
1001Produces a map of the union between the keys of `a` and `b`. If `b` shares a
1002key with `a`, the tuple from `b` is preserved.
1025 ?: (vor p.n.a p.n.b)
1027 [n.b $(a l.a, b l.b) $(a r.a, b r.b)]
1028 ?: (gor p.n.b p.n.a)
1029 $(a [n.a $(a l.a, b [n.b l.b ~]) r.a], b r.b)
1030 $(a [n.a l.a $(a r.a, b [n.b ~ r.b])], b l.b)
1032 [n.b $(b l.b, a l.a) $(b r.b, a r.a)]
1033 ?: (gor p.n.a p.n.b)
1034 $(b [n.b $(b l.b, a [n.a l.a ~]) r.b], a r.a)
1035 $(b [n.b l.b $(b r.b, a [n.a ~ r.a])], a l.a)
1041 > =m (my [['a' 1] ['b' 2] ~])
1043 > =o (my [['c' 3] ['d' 4] ~])
1046 [n=[p='b' q=2] l=[n=[p='d' q=4] l={} r={[p='a' q=1] [p='c' q=3]}] r=~]
1049 {[p='a' q=1] [p='b' q=2]}
1052 {[p='a' q=1] [p='c' q=3]}
1054 {[p='d' q=4] [p='a' q=1] [p='c' q=3]}
1062Iterates over every value in map `a` using gate `b`, which accepts both
1063the key and the value of each element as its sample.
1069`b` is a wet gate that accepts two nouns.
1082 [n=[p=p.n.a q=(b p.n.a q.n.a)] l=$(a l.a) r=$(a r.a)
1089 {[p='a' q=1] [p='b' q=2]}
1091 > (~(urn by m) |=(a=(pair * *) q.a))
1092 {[p='a' q=1] [p='b' q=2]}
1094 > (~(urn by m) |=(a=(pair * *) 7))
1095 {[p='a' q=7] [p='b' q=7]}
1097 > (~(urn by m) |=(a=(pair * *) p.a))
1098 {[p='a' q=97] [p='b' q=98]}
1107Produce the depth of the tree map `a`.
1122 ?~(a 0 +((add $(a l.a) $(a r.a))))
1128 > =m (my [['a' 1] ['b' 2] ~])
1130 > =o (my [['c' 3] ['d' 4] ~])
1138 > ~(wyt by (~(uni by m) o))
1148Produces a list of all values in map `a` that is prepended to list `b`,
1149which is empty by default.
1165 =+ b=`(list _?>(?=(^ a) q.n.a))`~
1168 $(a r.a, b [q.n.a $(a l.a)])
1174 > =m (my [['a' 1] ['b' 2] ~])
1175 [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