11Core whose arms contain a variety of functions that operate on `set`s. Its
12sample accepts the input `set` to be manipulated.
30 <13.evb [nlr(^$1{@tD $1}) <414.fvk 101.jzo 1.ypj %164>]>
37Computes the logical AND on every element in `a` slammed with `b`, producing a
44`b` is a wet gate that accepts a noun and produces a flag.
59 ?&((b n.a) $(a l.a) $(a r.a))
65 > =b (sy `(list [@t *])`[['a' 1] ['b' [2 3]] ~])
66 > (~(all in b) |=(a=* ?@(+.a & |)))
69 > =b (sy `(list @t)`['john' 'bonita' 'daniel' 'madeleine' ~])
70 > (~(all in b) |=(a=@t (gte a 100)))
79Computes the logical OR on every element of `a` slammed with `b`, producing a
86`b` is a gate that accepts a noun and produces a flag.
101 ?|((b n.a) $(a l.a) $(a r.a))
107 > =b (sy `(list [@t *])`[['a' 1] ['b' [2 3]] ~])
108 > (~(any in b) |=(a/* ?@(+.a & |)))
111 > =b (sy `(list @t)`['john' 'bonita' 'daniel' 'madeleine' ~])
112 > (~(any in b) |=(a=@t (lte a 100)))
121Computes whether `a` has a correct horizontal order and a correct vertical
122order, producing a flag.
135 ++ apt :: check correctness
138 =| [l=(unit) r=(unit)]
141 ?& ?~(l & (gor n.a u.l))
142 ?~(r & (gor u.r n.a))
143 ?~(l.a & ?&((mor n.a n.l.a) $(a l.a, l `n.a)))
144 ?~(r.a & ?&((mor n.a n.r.a) $(a r.a, r `n.a)))
154 > =a (sy [1 2 3 4 5 6 ~])
156 [n=6 l={5 4} r={1 3 2}]
162 [n=7 l={5 4} r={1 3 2}]
169See section [`2f`](/docs/hoon/reference/stdlib/2f) for more information on noun ordering.
176Splits set `a` into two sets `l` and `r`, with any noun `b` removed.
191 ++ bif :: splits a by b
213 > =a (sy `(list @)`[1 2 3 4 5 6 ~])
215 [n=6 l={5 4} r={1 3 2}]
218 [l=[n=4 l=[n=5 l={} r={}] r=~] r=[n=2 l=[n=1 l={} r={3}] r=~]]
221 [l=[n=6 l=[n=4 l={5} r={}] r=[n=2 l={1 3} r={}]] r=~]
229Removes `b` from the `set` `a`.
244 ++ del :: b without any a
266 > =b (sy `(list @t)`['a' 'b' 'c' ~])
268 [n='b' l=[n='c' l={} r={}] r=~]
270 > =b (sy `(list @t)`['john' 'bonita' 'daniel' 'madeleine' ~])
271 > (~(del in b) 'john')
272 [n='madeleine' l=[n='daniel' l={} r={'bonita'}] r=~]
274 > (~(del in b) 'susan')
275 [n='madeleine' l=[n='daniel' l={} r={'bonita'}] r=[n='john' l={} r={}]]
283Computes the difference between `a` and `b`, producing the set of items in `a`
331 > `(set @ud)`(~(dif in c) d)
334 > `(set @ud)`(~(dif in d) c)
343Produce the tree address of `b` within `a`.
353The `unit` of an atom.
358 ++ dig :: axis of a in b
363 ?: =(b n.a) [~ u=(peg c 2)]
365 $(a l.a, c (peg c 6))
366 $(a r.a, c (peg c 7))
373 > =a (sy `(list @)`[1 2 3 4 5 6 7 ~])
392For more on the tree addressing system, see section [1b](/docs/hoon/reference/stdlib/1b).
399Insert the elements of a `list` `b` into a `set` `a`.
414 ++ gas :: concatenate
416 |= b=(list _?>(?=(^ a) n.a))
420 $(b t.b, a (put i.b))
426 > =b `(set @t)`(sy `(list @t)`['bonita' 'madeleine' 'rudolf' 'john' ~])
428 {'bonita' 'madeleine' 'rudolf' 'john'}
430 > (~(gas in b) `(list @t)`['14' 'things' 'number' '1.337' ~])
431 [n='number' l={'1.337' '14'} r={'things' 'bonita' 'madeleine' 'rudolf' 'john'}]
433 > =s (sy `(list @t)`['a' 'b' 'c' 'd' 'e' ~])
434 > (~(gas in s) `(list @t)`['1' '2' '3' ~])
435 [n='e' l=[n='1' l={} r={'3' '2'}] r=[n='b' l={'d' 'a' 'c'} r={}]]
443Checks if `b` is an element of `a`, producing a flag.
462 :: wrap extracted item type in a unit because bunting fails
464 :: If we used the real item type of _?^(a n.a !!) as the sample type,
465 :: then hoon would bunt it to create the default sample for the gate.
467 :: However, bunting that expression fails if :a is ~. If we wrap it
468 :: in a unit, the bunted unit doesn't include the bunted item type.
470 :: This way we can ensure type safety of :b without needing to perform
471 :: this failing bunt. It's a hack.
474 |= b=(unit _?>(?=(^ a) n.a))
475 => .(b ?>(?=(^ b) u.b))
489 > =a (~(gas in `(set @t)`~) `(list @t)`['a' 'b' 'c' ~])
502Produces a set of the intersection between two sets of the same type,
518 ++ int :: intersection
531 a(l $(a l.a, b l.b), r $(a r.a, b r.b))
533 %- uni(a $(a l.a, r.b ~)) $(b r.b)
534 %- uni(a $(a r.a, l.b ~)) $(b l.b)
542 > (~(int in `(set @t)`(sy "acmo")) `(set @t)`(sy "ham"))
545 > (~(int in (sy "acmo")) ~)
548 > (~(int in `(set @t)`(sy "ac")) `(set @t)`(sy "ha"))
557Add an element `b` to the set `a`, producing a set.
572 ++ put :: puts b in a, sorted
596 > =a (~(gas in `(set @t)`~) `(list @t)`['a' 'b' 'c' ~])
597 > =b (~(put in a) 'd')
610Accumulate the elements of `a` using a gate `b`.
625 ++ rep :: reduce to product
627 |* b=_=>(~ |=([* *] +<+))
630 $(a r.a, +<+.b $(a l.a, +<+.b (b n.a +<+.b)))
636 > =a (~(gas in *(set @)) [1 2 3 ~])
640 > (~(rep in a) |=([a=@ b=@] (add a b)))
649Produce a `set` containing the products of gate `b` applied to each element
665 ++ run :: apply gate to values
668 =+ c=`(set _?>(?=(^ a) (b n.a)))`~
670 =. c (~(put in c) (b n.a))
678 > =s (sy ~["a" "A" "b" "c"])
691Flattens the `set` `a` into a `list`.
704 ++ tap :: convert to list
707 =+ b=`(list _?>(?=(^ a) n.a))`~
711 $(a r.a, b [n.a $(a l.a)])
718 > =s (sy `(list @t)`['a' 'b' 'c' 'd' 'e' ~])
720 [n='e' l={} r={'d' 'a' 'c' 'b'}]
723 ~['b' 'c' 'a' 'd' 'e']
731Produces a set of the union between two sets of the same type, `a` and
759 b(l $(a l.a, b l.b), r $(a r.a, b r.b))
762 $(l.a $(a l.a, r.b ~), b r.b)
763 $(r.a $(a r.a, l.b ~), b l.b)
765 $(l.b $(b l.b, r.a ~), a r.a)
766 $(r.b $(b r.b, l.a ~), a l.a)
774 > (~(uni in `(set @t)`(sy "ac")) `(set @)`(sy "ha"))
775 [n='c' l={'a'} r={'h'}]
777 > (~(uni in `(set @t)`(sy "acmo")) ~)
778 [n='c' l={'a'} r={'m' 'o'}]
780 > (~(uni in `(set @t)`(sy "acmo")) `(set @t)`(sy "ham"))
781 [n='c' l={'a'} r={'m' 'o' 'h'}]
783 > (~(uni in `(set @t)`(sy "acmo")) `(set @t)`(sy "lep"))
784 [n='e' l={} r={'a' 'c' 'm' 'l' 'o' 'p'}]
792Produces the number of elements in set `a` as an atom.
805 ++ wyt :: size of set
809 ?~(a 0 +((add $(a l.a) $(a r.a))))
817 > =a (~(put in (~(put in (sy)) 'a')) 'b')
821 > =b (sy `(list @t)`['john' 'bonita' 'daniel' 'madeleine' ~])
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