11Core whose arms contain a variety of functions that operate on `set`s. Its
12sample accepts the input `set` to be manipulated.
30<16.ufw [a=?(%~ [?(n=@tD n=#1) l=nlr(?(@tD #1)) r=nlr(?(@tD ^#1.?(@tD #1)))]) <123.zao 46.hgz 1.pnw %140>]>
37Computes the logical AND on every element in `a` slammed with `b`, producing a
42`a` is a `set`, and is the sample of `+in`.
44`b` is a gate that accepts a noun and produces a flag.
59 ?&((b n.a) $(a l.a) $(a r.a))
65> (~(all in (silt ~[1 2 3 4])) |=(a=@ (lth a 5)))
68> (~(all in (silt ~[1 2 3 4 5])) |=(a=@ (lth a 5)))
78Computes the logical OR on every element of `a` slammed with `b`, producing a
83`a` is a `set`, and is the sample of `+in`.
85`b` is a gate that accepts a noun and produces a flag.
100 ?|((b n.a) $(a l.a) $(a r.a))
106> (~(any in (silt ~[2 3 4 5])) |=(a=@ (lth a 3)))
109> (~(any in (silt ~[3 4 5])) |=(a=@ (lth a 3)))
119Computes whether `a` has a correct horizontal order and a correct vertical
120order, producing a flag.
136 =| [l=(unit) r=(unit)]
139 ?& ?~(l & (gor n.a u.l))
140 ?~(r & (gor u.r n.a))
141 ?~(l.a & ?&((mor n.a n.l.a) $(a l.a, l `n.a)))
142 ?~(r.a & ?&((mor n.a n.r.a) $(a r.a, r `n.a)))
169See section [`2f`](/docs/hoon/reference/stdlib/2f) for more information on noun ordering.
177Splits set `a` into sets `l` and `r`, which contain the items either side of `b` but not including `b`.
181`a` is a set, and is the sample of `+in`.
214> =a `(set @)`(silt (gulf 1 20))
216{17 8 20 13 11 5 19 7 15 10 18 14 6 12 9 1 2 3 16 4}
219[l=[n=11 l={17 8 20 13} r={5 19 7 15}] r=[n=12 l={18 14 6} r={9 1 2 3 16 4}]]
221> `[(set @) (set @)]`(~(bif in a) 10)
222[{17 8 20 13 11 5 19 7 15} {18 14 6 12 9 1 2 3 16 4}]
227Note that `set`s are horizontally ordered by the [mug](/docs/hoon/reference/stdlib/2e#mug) hash of their items and vertically ordered by the double-`mug` hash of their items. This means bifurcating the set of numbers `(silt ~[10 20 30 40 50])` at `30` will not produce `[{10 20} {40 50}]`, but rather `[{20} {10 40 50}]` due to the tree structure resulting from their `mug` hashes.
235Removes `b` from the `set` `a`.
239`a` is a set, and is the sample of `+in`.
271> `(set @)`(~(del in (silt ~[1 2 3 4 5])) 3)
276> `(set @t)`(~(del in (silt ~['foo' 'bar' 'baz'])) 'bar')
281> `(set @)`(~(del in (silt ~[1 2 3 4 5])) 10)
286> `(set @)`(~(del in ~) 10)
296Computes the difference between `a` and `b`, producing the set of items in `a`
301`a` is a set, and is the sample of `+in`.
336> =a (silt ~[1 2 3 4 5])
339> `(set @)`(~(dif in a) b)
349Produce the tree address of `b` within `a`.
353`a` is a set, and is the sample of `+in`.
359The `unit` of an atom.
369 ?: =(b n.a) [~ u=(peg c 2)]
371 $(a l.a, c (peg c 6))
372 $(a r.a, c (peg c 7))
378> =a (silt ~[1 2 3 4 5 6 7])
398For more on the tree addressing system, see section [1b](/docs/hoon/reference/stdlib/1b).
406Insert the elements of a `list` `b` into a `set` `a`.
410`a` is a set, and is the sample of `+in`.
423 |= b=(list _?>(?=(^ a) n.a))
427 $(b t.b, a (put i.b))
433> =a (silt ~['foo' 'bar' 'baz'])
437> `(set @t)`(~(gas in a) ~['foo' 'foo' 'foo' 'foo'])
440> `(set @t)`(~(gas in a) ~['abc' 'xyz' '123'])
441{'xyz' 'bar' 'baz' 'foo' 'abc' '123'}
450Checks if `b` is an element of `a`, producing a flag.
454`a` is a set, and is the sample of `+in`.
470 |= b=(unit _?>(?=(^ a) n.a))
471 => .(b ?>(?=(^ b) u.b))
485> =a (silt ~[1 2 3 4 5])
500Produces a set of the intersection between two sets of the same type,
505`a` is a set, and is the sample of `+in`.
529 a(l $(a l.a, b l.b), r $(a r.a, b r.b))
531 %- uni(a $(a l.a, r.b ~)) $(b r.b)
532 %- uni(a $(a r.a, l.b ~)) $(b l.b)
539> `(set @tD)`(~(int in (silt "foobar")) (silt "bar"))
542> `(set @tD)`(~(int in (silt "foobar")) ~)
545> `(set @tD)`(~(int in (silt "foobar")) (silt "baz"))
555Add an element `b` to the set `a`, producing a set.
559`a` is a set, and is the sample of `+in`.
594> `(set @)`(~(put in (silt ~[1 2 3])) 4)
597> `(set @)`(~(put in `(set @)`~) 42)
607Accumulate the elements of `a` using binary gate `b`.
611`a` is a `set`, and is the sample of `+in`.
624 |* b=_=>(~ |=([* *] +<+))
627 $(a r.a, +<+.b $(a l.a, +<+.b (b n.a +<+.b)))
633> (~(rep in (silt ~[1 2 3 4 5])) add)
638> `@t`(~(rep in (silt ~['foo' 'bar' 'baz'])) |=(a=[@ @] (cat 3 a)))
648Produce a `set` containing the products of gate `b` applied to each element
667 =+ c=`(set _?>(?=(^ a) (b n.a)))`~
669 =. c (~(put in c) (b n.a))
677> =s (silt ~["a" "A" "b" "c"])
691Flattens the `set` `a` into a `list`.
707 =+ b=`(list _?>(?=(^ a) n.a))`~
711 $(a r.a, b [n.a $(a l.a)])
717> ~(tap in (silt "foobar"))
722> ~(tap in (silt ~[1 2 3 4 5]))
732Produces a set of the union between two sets of the same type, `a` and
737`a` is a set, and is the sample of `+in`.
760 b(l $(a l.a, b l.b), r $(a r.a, b r.b))
763 $(l.a $(a l.a, r.b ~), b r.b)
764 $(r.a $(a r.a, l.b ~), b l.b)
766 $(l.b $(b l.b, r.a ~), a r.a)
767 $(r.b $(b r.b, l.a ~), a l.a)
774> =a (silt ~[1 2 3 4 5])
775> =b (silt ~[4 5 6 7 8])
777> `(set @)`(~(uni in a) b)
780> `(set @)`(~(uni in a) ~)
783> `(set @)`(~(uni in `(set @)`~) b)
793Produces the number of elements in set `a` as an atom.
810 ?~(a 0 +((add $(a l.a) $(a r.a))))
817> ~(wyt in (silt ~[1 2 3 4]))
822> ~(wyt in `(set @)`~)
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