on master help sign in
Merge pull request #287 from urbit/rmariani-patch-17
f5800d1Joshua Reagan
docs/hoon/library/2h.md+343−241
@@ -9,136 +9,221 @@ navhome: /docs/
9
9
10Set operations
10Set operations
11
11
12−Core whose arms contain a variety of functions that operate on `++set`s. Its sample accepts the input `++set` to be manipulated.
12+Core whose arms contain a variety of functions that operate on `set`s. Its
13+sample accepts the input `set` to be manipulated.
13
14
14−Accepts
15+#### Accepts
15−-------
16
16
17−A `++set`.
17+A `set`.
18
18
19−Source
19+#### Source
20−------
21
20
22− ++ in :: set engine
21+ ++ in
23 ~/ %in
22 ~/ %in
24− |_ a/(set)
23+ |_ a=(set)
25
24
26−Examples
25+#### Examples
27−--------
28
26
29− > ~(. in (sa "asd"))
27+ > ~(. in (sy "asd"))
30 <13.evb [nlr(^$1{@tD $1}) <414.fvk 101.jzo 1.ypj %164>]>
28 <13.evb [nlr(^$1{@tD $1}) <414.fvk 101.jzo 1.ypj %164>]>
31
29
32### `+-all:in`
30### `+-all:in`
33
31
34Logical AND
32Logical AND
35
33
36−Computes the logical AND on every element in `a` slammed with `b`,
34+Computes the logical AND on every element in `a` slammed with `b`, producing a
37−producing a boolean.
35+flag.
38
36
39−Accepts
37+#### Accepts
40−-------
41
38
42−`a` is a `++set`.
39+`a` is a `set`.
43
40
44−`b` is a wet gate that accepts a noun and produces a boolean.
41+`b` is a wet gate that accepts a noun and produces a flag.
45
42
46−Produces
43+#### Produces
47−--------
48
44
49−A boolean.
45+A flag.
50
46
51−Source
47+#### Source
52−------
53
48
54− +- all :: logical AND
49+ +- all
55 ~/ %all
50 ~/ %all
56− |* b/$-(* ?)
51+ |* b=$-(* ?)
57 |- ^- ?
52 |- ^- ?
58 ?~ a
53 ?~ a
59 &
54 &
60 ?&((b n.a) $(a l.a) $(a r.a))
55 ?&((b n.a) $(a l.a) $(a r.a))
61
56
57+#### Examples
62
58
63−Examples
64−--------
65−
66− > =b (sa `(list [@t *])`[['a' 1] ['b' [2 3]] ~])
59+ > =b (sy `(list [@t *])`[['a' 1] ['b' [2 3]] ~])
67− > (~(all in b) |=(a/* ?@(+.a & |)))
60+ > (~(all in b) |=(a=* ?@(+.a & |)))
68 %.n
61 %.n
69− > =b (sa `(list @t)`['john' 'bonita' 'daniel' 'madeleine' ~])
70− > (~(all in b) |=(a/@t (gte a 100)))
71− %.y
72
62
73−------------------------------------------------------------------------
63+ > =b (sy `(list @t)`['john' 'bonita' 'daniel' 'madeleine' ~])
64+ > (~(all in b) |=(a=@t (gte a 100)))
65+ %.y
74
66
67+***
75### `+-any:in`
68### `+-any:in`
76
69
77Logical OR
70Logical OR
78
71
79−Computes the logical OR on every element of `a` slammed with `b`.
72+Computes the logical OR on every element of `a` slammed with `b`, producing a
73+flag.
80
74
81−Accepts
75+#### Accepts
82−-------
83
76
84−`a` is a `++set`.
77+`a` is a `set`.
85
78
86−`b` is a gate that accepts a noun and produces a boolean.
79+`b` is a gate that accepts a noun and produces a flag.
87
80
88−Produces
81+#### Produces
89−--------
90
82
91−A boolean.
83+A flag.
92
84
93−Source
85+#### Source
94−------
95
86
96− +- any :: logical OR
87+ +- any
97 ~/ %any
88 ~/ %any
98− |* b/$-(* ?)
89+ |* b=$-(* ?)
99 |- ^- ?
90 |- ^- ?
100 ?~ a
91 ?~ a
101 |
92 |
102 ?|((b n.a) $(a l.a) $(a r.a))
93 ?|((b n.a) $(a l.a) $(a r.a))
103− ::
104
94
105
95
106−Examples
96+#### Examples
107−--------
108
97
109− > =b (sa `(list [@t *])`[['a' 1] ['b' [2 3]] ~])
98+ > =b (sy `(list [@t *])`[['a' 1] ['b' [2 3]] ~])
110 > (~(any in b) |=(a/* ?@(+.a & |)))
99 > (~(any in b) |=(a/* ?@(+.a & |)))
111 %.y
100 %.y
101+
112− > =b (sa `(list @t)`['john' 'bonita' 'daniel' 'madeleine' ~])
102+ > =b (sy `(list @t)`['john' 'bonita' 'daniel' 'madeleine' ~])
113− > (~(any in b) |=(a/@t (lte a 100)))
103+ > (~(any in b) |=(a=@t (lte a 100)))
114 %.n
104 %.n
115
105
116−------------------------------------------------------------------------
106+***
107+#### `+-apt:in`
108+
109+Check correctness
110+
111+Computes whether `a` has a correct horizontal order and a correct vertical
112+order, producing a flag.
113+
114+#### Accepts
115+
116+`a` is a set.
117
117
118+#### Produces
119+
120+A flag.
121+
122+#### Source
123+
124+ +- apt
125+ =| [l=(unit) r=(unit)]
126+ |- ^- ?
127+ ?~ a &
128+ ?& ?~(l & (hor n.a u.l))
129+ ?~(r & (hor u.r n.a))
130+ ?~(l.a & ?&((vor n.a n.l.a) $(a l.a, l `n.a)))
131+ ?~(r.a & ?&((vor n.a n.r.a) $(a r.a, r `n.a)))
132+ ==
133+
134+#### Examples
135+
136+ > ~(apt in ~)
137+ %.y
138+
139+ > =a (sy [1 2 3 4 5 6 ~])
140+ [n=6 l={5 4} r={1 3 2}]
141+ > ~(apt in a)
142+ %.y
143+
144+ > =z ?~ a ~ a(n 7)
145+ > z
146+ [n=7 l={5 4} r={1 3 2}]
147+ > ~(apt in z)
148+ %.n
149+
150+
151+#### Discussion
152+
153+See section [`2f`](../2f) for more information on noun ordering.
154+
155+***
156+### `+-bif:in`
157+
158+Bifurcate
159+
160+Splits set `a` into two sets `l` and `r`, with any noun `b` removed.
161+
162+#### Accepts
163+
164+`a` is a set.
165+
166+`b` is a noun.
167+
168+#### Produces
169+
170+A cell of two sets.
171+
172+#### Source
173+
174+ +- bif
175+ ~/ %bif
176+ |* b=*
177+ ^+ [l=a r=a]
178+ =< [+< +>]
179+ |- ^+ a
180+ ?~ a
181+ [b ~ ~]
182+ ?: =(b n.a)
183+ a
184+ ?: (hor b n.a)
185+ =+ c=$(a l.a)
186+ ?> ?=(^ c)
187+ [n.c l.c [n.a r.c r.a]]
188+ =+ c=$(a r.a)
189+ ?> ?=(^ c)
190+ [n.c [n.a l.a l.c] r.c]
191+
192+
193+#### Examples
194+
195+ > =a (sy `(list @)`[1 2 3 4 5 6 ~])
196+ > a
197+ [n=6 l={5 4} r={1 3 2}]
198+
199+ > (~(bif in a) 6)
200+ [l=[n=4 l=[n=5 l={} r={}] r=~] r=[n=2 l=[n=1 l={} r={3}] r=~]]
201+
202+ > (~(bif in a) 100)
203+ [l=[n=6 l=[n=4 l={5} r={}] r=[n=2 l={1 3} r={}]] r=~]
204+
205+***
118### `+-del:in`
206### `+-del:in`
119
207
120Remove noun
208Remove noun
121
209
122−Removes `b` from the `++set` `a`.
210+Removes `b` from the `set` `a`.
123
211
124−Accepts
212+#### Accepts
125−-------
126
213
127`a` is a set.
214`a` is a set.
128
215
129`b` is a noun.
216`b` is a noun.
130
217
131−Produces
218+#### Produces
132−--------
133
219
134A set.
220A set.
135
221
136−Source
222+#### Source
137−------
138
223
139− +- del :: b without any a
224+ +- del
140 ~/ %del
225 ~/ %del
141− |* b/*
226+ |* b=*
142 |- ^+ a
227 |- ^+ a
143 ?~ a
228 ?~ a
144 ~
229 ~
@@ -152,46 +237,95 @@ Source
152 ?: (vor n.l.a n.r.a)
237 ?: (vor n.l.a n.r.a)
153 [n.l.a l.l.a $(l.a r.l.a)]
238 [n.l.a l.l.a $(l.a r.l.a)]
154 [n.r.a $(r.a l.r.a) r.r.a]
239 [n.r.a $(r.a l.r.a) r.r.a]
155− ::
156
240
157
241
158−Examples
159−--------
160
242
243+#### Examples
244+
161− > =b (sa `(list @t)`['a' 'b' 'c' ~])
245+ > =b (sy `(list @t)`['a' 'b' 'c' ~])
162 > (~(del in b) 'a')
246 > (~(del in b) 'a')
163 {'c' 'b'}
247 {'c' 'b'}
248+
164− > =b (sa `(list @t)`['john' 'bonita' 'daniel' 'madeleine' ~])
249+ > =b (sy `(list @t)`['john' 'bonita' 'daniel' 'madeleine' ~])
165 > (~(del in b) 'john')
250 > (~(del in b) 'john')
166 {'bonita' 'madeleine' 'daniel'}
251 {'bonita' 'madeleine' 'daniel'}
252+
167 > (~(del in b) 'susan')
253 > (~(del in b) 'susan')
168 {'bonita' 'madeleine' 'daniel' 'john'}
254 {'bonita' 'madeleine' 'daniel' 'john'}
169
255
170−------------------------------------------------------------------------
171
256
257+***
258+### `+-dif:in`
259+
260+Difference
261+
262+Computes the difference between `a` and `b`, producing the set of items in `a`
263+that are not in `b`.
264+
265+#### Accepts
266+
267+`a` is a set.
268+
269+`b` is a set.
270+
271+#### Produces
272+
273+A set.
274+
275+#### Source
276+
277+ +- dif
278+ ~/ %dif
279+ |* b=_a
280+ |- ^+ a
281+ ?~ b
282+ a
283+ =+ c=(bif n.b)
284+ ?> ?=(^ c)
285+ =+ d=$(a l.c, b l.b)
286+ =+ e=$(a r.c, b r.b)
287+ |- ^- {$?($~ _a)}
288+ ?~ e d
289+ ?: (vor n.d n.e)
290+ [n.d l.d $(d r.d)]
291+ [n.e $(e l.e) r.e]
292+
293+
294+#### Examples
295+
296+ > ((~(dif in (sy 1 2 3 ~)) (sy 2 3 4 ~))
297+ [n=1 l=~ r=~]
298+
299+ > (~(dif in (sy 2 3 4 ~)) (sy 1 2 3 ~))
300+ [n=4 l=~ r=~]
301+
302+ > `(set @ud)`((~(dif in (sy 1 2 3 ~)) (sy 2 3 4 ~))
303+ {1}
304+
305+ > `(set @ud)`(~(dif in (sy 2 3 4 ~)) (sy 1 2 3 ~))
306+ {4}
307+
308+***
172### `+-dig:in`
309### `+-dig:in`
173
310
174−Axis a in b
311+Address b in a
175
312
176−Produce the axis of `b` within `a`.
313+Produce the tree address of `b` within `a`.
177
314
178−Accepts
315+#### Accepts
179−-------
180
316
181−`a` is a `++set`.
317+`a` is a set.
182
318
183`b` is a noun.
319`b` is a noun.
184
320
185−Produces
321+#### Produces
186−--------
187
322
188−The `++unit` of an atom.
323+The `unit` of an atom.
189
324
190−Source
325+#### Source
191−------
192
326
193− +- dig :: axis of a in b
327+ +- dig
194− |= b/*
328+ |= b=*
195 =+ c=1
329 =+ c=1
196 |- ^- (unit @)
330 |- ^- (unit @)
197 ?~ a ~
331 ?~ a ~
@@ -199,69 +333,71 @@ Source
199 ?: (hor b n.a)
333 ?: (hor b n.a)
200 $(a l.a, c (peg c 6))
334 $(a l.a, c (peg c 6))
201 $(a r.a, c (peg c 7))
335 $(a r.a, c (peg c 7))
202− ::
203
336
204
337
205
338
206−Examples
339+#### Examples
207−--------
208
340
209− > =a (sa `(list @)`[1 2 3 4 5 6 7 ~])
341+ > =a (sy `(list @)`[1 2 3 4 5 6 7 ~])
210 > a
342 > a
211 {5 4 7 6 1 3 2}
343 {5 4 7 6 1 3 2}
344+
212 > -.a
345 > -.a
213 n=6
346 n=6
347+
214 > (~(dig in a) 7)
348 > (~(dig in a) 7)
215 [~ 12]
349 [~ 12]
350+
216 > (~(dig in a) 2)
351 > (~(dig in a) 2)
217 [~ 14]
352 [~ 14]
353+
218 > (~(dig in a) 6)
354 > (~(dig in a) 6)
219 [~ 2]
355 [~ 2]
220
356
221−------------------------------------------------------------------------
357+#### Discussion
222
358
359+For more on the tree addressing system, see section [1b](../1b).
360+
361+***
223### `+-gas:in`
362### `+-gas:in`
224
363
225Concatenate
364Concatenate
226
365
227−Insert the elements of a `++list` `b` into a `++set` `a`.
366+Insert the elements of a `list` `b` into a `set` `a`.
228
367
229−Accepts
368+#### Accepts
230−-------
231
369
232`a` is a set.
370`a` is a set.
233
371
234`b` is a list.
372`b` is a list.
235
373
236−Produces
374+#### Produces
237−--------
238
375
239−A `++set`.
376+A `set`.
240
377
241−Source
378+#### Source
242−------
243
379
244− +- gas :: concatenate
380+ +- gas
245 ~/ %gas
381 ~/ %gas
246− |= b/(list _?>(?=(^ a) n.a))
382+ |= b=(list _?>(?=(^ a) n.a))
247 |- ^+ a
383 |- ^+ a
248 ?~ b
384 ?~ b
249 a
385 a
250 $(b t.b, a (put i.b))
386 $(b t.b, a (put i.b))
251− ::
252
387
253
388
254−Examples
389+#### Examples
255−--------
256
390
257 > b
391 > b
258 {'bonita' 'madeleine' 'rudolf' 'john'}
392 {'bonita' 'madeleine' 'rudolf' 'john'}
393+
259 > (~(gas in b) `(list @t)`['14' 'things' 'number' '1.337' ~])
394 > (~(gas in b) `(list @t)`['14' 'things' 'number' '1.337' ~])
260 {'1.337' '14' 'number' 'things' 'bonita' 'madeleine' 'rudolf' 'john'}
395 {'1.337' '14' 'number' 'things' 'bonita' 'madeleine' 'rudolf' 'john'}
396+
261 > (~(gas in s) `(list ,@t)`['1' '2' '3' ~])
397 > (~(gas in s) `(list ,@t)`['1' '2' '3' ~])
262 {'1' '3' '2' 'e' 'd' 'a' 'c' 'b'}
398 {'1' '3' '2' 'e' 'd' 'a' 'c' 'b'}
263
399
264−------------------------------------------------------------------------
400+***
265
401
266### `+-has:in`
402### `+-has:in`
267
403
@@ -269,24 +405,21 @@ b in a?
269
405
270Checks if `b` is an element of `a`, producing a boolean.
406Checks if `b` is an element of `a`, producing a boolean.
271
407
272−Accepts
408+#### Accepts
273−-------
274
409
275−`a` is a [`++set`]().
410+`a` is a set.
276
411
277−`b` is a [noun]().
412+`b` is a noun.
278
413
279−Produces
414+#### Produces
280−--------
281
415
282A boolean.
416A boolean.
283
417
284−Source
418+#### Source
285−------
286
419
287− +- has :: b exists in a check
420+ +- has
288 ~/ %has
421 ~/ %has
289− |* b/*
422+ |* b=*
290 |- ^- ?
423 |- ^- ?
291 ?~ a
424 ?~ a
292 |
425 |
@@ -298,42 +431,38 @@ Source
298 ::
431 ::
299
432
300
433
301−Examples
434+#### Examples
302−--------
303
435
304− > =a (~(gas in `(set @t)`~) `(list @t)`[`a` `b` `c` ~])
436+ > =a (~(gas in `(set @t)`~) `(list @t)`['a' 'b' 'c' ~])
305− > (~(has in a) `a`)
437+ > (~(has in a) 'a')
306 %.y
438 %.y
439+
307 > (~(has in a) 'z')
440 > (~(has in a) 'z')
308 %.n
441 %.n
309
442
310−------------------------------------------------------------------------
443+***
311−
312### `+-int:in`
444### `+-int:in`
313
445
314Intersection
446Intersection
315
447
316−Produces a set of the intersection between two `++set`s of the same type,
448+Produces a set of the intersection between two sets of the same type,
317`a` and `b`.
449`a` and `b`.
318
450
319−Accepts
451+#### Accepts
320−-------
321
452
322`a` is a set.
453`a` is a set.
323
454
324`b` is a set.
455`b` is a set.
325
456
326−Produces
457+#### Produces
327−--------
328
458
329−A `++set`.
459+A `set`.
330
460
331−Source
461+#### Source
332−------
333
462
334− +- int :: intersection
463+ +- int
335 ~/ %int
464 ~/ %int
336− |* b/_a
465+ |* b=_a
337 |- ^+ a
466 |- ^+ a
338 ?~ b
467 ?~ b
339 ~
468 ~
@@ -350,44 +479,42 @@ Source
350
479
351
480
352
481
353−Examples
482+#### Examples
354−--------
355
483
356− > (~(int in (sa "ac")) (sa "ha"))
484+ > (~(int in `(set @t)`(sy "acmo")) `(set @t)`(sy "ham"))
357− {~~a}
485+ [n='m' l={'a'} r={}]
358− > (~(int in (sa "acmo")) ~)
359− {}
360− > (~(int in (sa "acmo")) (sa "ham"))
361− {~~a ~~m}
362− > (~(int in (sa "acmo")) (sa "lep"))
363− {}
364
486
365−------------------------------------------------------------------------
487+ > (~(int in (sy "acmo")) ~)
488+ ~
366
489
490+ > (~(int in `(set @t)`(sy "ac")) `(set @t)`(sy "ha"))
491+ [n='a' l={} r={}]
492+
493+ > (~(int in (sy "acmo")) (sy "lep"))
494+ {}
495+
496+***
367### `+-put:in`
497### `+-put:in`
368
498
369Put b in a
499Put b in a
370
500
371−Add an element `b` to the `++set` `a`.
501+Add an element `b` to the set `a`, producing a set.
372
502
373−Accepts
503+#### Accepts
374−-------
375
504
376`a` is a set.
505`a` is a set.
377
506
378`b` is a noun.
507`b` is a noun.
379
508
380−Produces
509+#### Produces
381−--------
382
510
383−A `++set`.
511+A `set`.
384
512
385−Source
513+#### Source
386−------
387
514
388− +- put :: puts b in a, sorted
515+ +- put
389 ~/ %put
516 ~/ %put
390− |* b/*
517+ |* b=*
391 |- ^+ a
518 |- ^+ a
392 ?~ a
519 ?~ a
393 [b ~ ~]
520 [b ~ ~]
@@ -404,175 +531,152 @@ Source
404 ?: (vor n.a n.c)
531 ?: (vor n.a n.c)
405 [n.a l.a c]
532 [n.a l.a c]
406 [n.c [n.a l.a l.c] r.c]
533 [n.c [n.a l.a l.c] r.c]
407− ::
408
534
409
535
410−Examples
536+#### Examples
411−--------
412
537
413− > =a (~(gas in `(set @t)`~) `(list @t)`[`a` `b` `c` ~])
538+ > =a (~(gas in `(set @t)`~) `(list @t)`['a' 'b' 'c' ~])
414− > =b (~(put in a) `d`)
539+ > =b (~(put in a) 'd')
415− > b
540+ > `(set @t)`b
416− {`d` `a` `c` `b`}
541+ {'d' 'a' 'c' 'b'}
417− > -.l.+.b
418− n=`d`
419
542
420−------------------------------------------------------------------------
543+ > -.l.+.b
544+ n='d'
421
545
546+***
422### `+-rep:in`
547### `+-rep:in`
423
548
424Accumulate
549Accumulate
425
550
426Accumulate the elements of `a` using a gate `b`.
551Accumulate the elements of `a` using a gate `b`.
427
552
428−Accepts
553+#### Accepts
429−--------
430
554
431−`a` is a `++set`.
555+`a` is a `set`.
432
556
433`b` is a gate.
557`b` is a gate.
434
558
435−Produces
559+#### Produces
436−--------
437
560
438A noun.
561A noun.
439
562
440−Source
563+#### Source
441−------
442
564
443 +- rep :: replace by product
565 +- rep :: replace by product
444− |* b/_|=({* *} +<+)
566+ |* b=_|=([* *] +<+)
445 |-
567 |-
446 ?~ a +<+.b
568 ?~ a +<+.b
447 $(a r.a, +<+.b $(a l.a, +<+.b (b n.a +<+.b)))
569 $(a r.a, +<+.b $(a l.a, +<+.b (b n.a +<+.b)))
448
570
449
571
450
572
451−Examples
573+#### Examples
452−--------
453
574
454 > =a (~(gas in *(set @)) [1 2 3 ~])
575 > =a (~(gas in *(set @)) [1 2 3 ~])
455− > a
576+ > `(set @)`a
456 {1 3 2}
577 {1 3 2}
457− > (~(rep in a) |=([a/@ b/@] (add a b)))
458− 6
459
578
460−------------------------------------------------------------------------
579+ > (~(rep in a) |=([a=@ b=@] (add a b)))
580+ b=6
461
581
582+***
462### `+-run:in`
583### `+-run:in`
463
584
464−Apply gate to set (often called *map*)
585+Apply gate to set
465
586
466−Produce a `++set` containing the products of gate `b` applied to each element
587+Produce a `set` containing the products of gate `b` applied to each element
467in `a`.
588in `a`.
468
589
469−Accepts
590+#### Accepts
470−-------
471
591
472−`a` is a `++set`.
592+`a` is a `set`.
473
593
474`b` is a gate.
594`b` is a gate.
475
595
476−Produces
596+#### Produces
477−--------
478
597
479A set.
598A set.
480
599
481−Source
600+#### Source
482−------
483
601
484− +- run :: apply gate to values
602+ +- run
485 ~/ %run
603 ~/ %run
486− |* b/gate
604+ |* b=gate
487− =| c/(set _?>(?=(^ a) (b n.a)))
605+ =| c=(set _?>(?=(^ a) (b n.a)))
488 |- ?~ a c
606 |- ?~ a c
489 =. c (~(put in c) (b n.a))
607 =. c (~(put in c) (b n.a))
490 =. c $(a l.a, c c)
608 =. c $(a l.a, c c)
491 $(a r.a, c c)
609 $(a r.a, c c)
492
610
493
611
494−
495−Examples
612+#### Examples
496−--------
497
613
498 > =s (sy ~["a" "A" "b" "c"])
614 > =s (sy ~["a" "A" "b" "c"])
499− > s
615+ > `(set tape)`s
500 {"A" "a" "c" "b"}
616 {"A" "a" "c" "b"}
501− > (~(run in s) cuss)
502− {'A' 'C' 'B'}
503
617
504−------------------------------------------------------------------------
618+ > (~(run in s) cuss)
619+ {"A" "C" "B"}
505
620
621+***
506### `+-tap:in`
622### `+-tap:in`
507
623
508Set to list
624Set to list
509
625
510−Flattens the `++set` `a` into a `++list`.
626+Flattens the `set` `a` into a `list`.
511
627
512−Accepts
628+#### Accepts
513−-------
514
629
515`a` is an set.
630`a` is an set.
516
631
517−Produces
632+#### Produces
518−--------
519
633
520A list.
634A list.
521
635
522−Source
636+#### Source
523−------
524
637
525− +- tap :: convert to list
638+ +- tap
526 ~/ %tap
639 ~/ %tap
527− |= b/(list _?>(?=(^ a) n.a))
640+ |= b=(list _?>(?=(^ a) n.a))
528 ^+ b
641 ^+ b
529 ?~ a
642 ?~ a
530 b
643 b
531 $(a r.a b [n.a $(a l.a)])
644 $(a r.a b [n.a $(a l.a)])
532− ::
533
645
534
646
535
647
536−Examples
648+#### Examples
537−--------
538
649
539− > =s (sa `(list @t)`['a' 'b' 'c' 'd' 'e' ~])
650+ > =s (sy `(list @t)`['a' 'b' 'c' 'd' 'e' ~])
540 > s
651 > s
541− {'e' 'd' 'a' 'c' 'b'}
652+ [n='e' l={} r={'d' 'a' 'c' 'b'}]
542− > (~(tap in s) `(list @t)`['1' '2' '3' ~])
543− ~['b' 'c' 'a' 'd' 'e' '1' '2' '3']
544− > b
545− {'bonita' 'madeleine' 'daniel' 'john'}
546− ~zod/try=> (~(tap in b) `(list ,@t)`['david' 'people' ~])
547− ~['john' 'daniel' 'madeleine' 'bonita' 'david' 'people']
548
653
549−------------------------------------------------------------------------
654+ > ~(tap in s)
655+ ~['b' 'c' 'a' 'd' 'e']
550
656
657+***
551### `+-uni:in`
658### `+-uni:in`
552
659
553Union
660Union
554
661
555−Produces a set of the union between two [`++set`]()s of the same type, `a` and
662+Produces a set of the union between two sets of the same type, `a` and
556`b`.
663`b`.
557
664
558−Accepts
665+#### Accepts
559−-------
560
666
561`a` is a set.
667`a` is a set.
562
668
563`b` is a set.
669`b` is a set.
564
670
565−Produces
671+#### Produces
566−--------
567
672
568A set.
673A set.
569
674
570−Source
675+#### Source
571−------
572
676
573− +- uni :: union
677+ +- uni
574 ~/ %uni
678 ~/ %uni
575− |* b/_a
679+ |* b=_a
576 ?: =(a b) a
680 ?: =(a b) a
577 |- ^+ a
681 |- ^+ a
578 ?~ b
682 ?~ b
@@ -593,38 +697,37 @@ Source
593 ::
697 ::
594
698
595
699
596−Examples
597−--------
598
700
701+#### Examples
702+
599− > (~(uni in (sa "ac")) (sa "ha"))
703+ > (~(uni in `(set @t)`(sy "ac")) `(set @)`(sy "ha"))
600− {~~a ~~c ~~h}
704+ [n='c' l={'a'} r={'h'}]
705+
601− > (~(uni in (sa "acmo")) ~)
706+ > (~(uni in `(set @t)`(sy "acmo")) ~)
602− {~~a ~~c ~~m ~~o}
707+ [n='c' l={'a'} r={'m' 'o'}]
708+
603− > (~(uni in (sa "acmo")) (sa "ham"))
709+ > (~(uni in `(set @t)`(sy "acmo")) `(set @t)`(sy "ham"))
604− {~~a ~~c ~~m ~~o ~~h}
605− > (~(uni in (sa "acmo")) (sa "lep"))
606− {~~e ~~a ~~c ~~m ~~l ~~o ~~p}
710+ [n='c' l={'a'} r={'m' 'o' 'h'}]
607
711
608−------------------------------------------------------------------------
712+ > (~(uni in `(set @t)`(sy "acmo")) `(set @t)`(sy "lep"))
713+ [n='e' l={} r={'a' 'c' 'm' 'l' 'o' 'p'}]
609
714
715+***
610### `+-wyt:in`
716### `+-wyt:in`
611
717
612Set size
718Set size
613
719
614−Produce the number of elements in [`++set`]() `a` as an atom.
720+Produces the number of elements in set `a` as an atom.
615
721
616−Accepts
722+#### Accepts
617−-------
618
723
619`a` is an set.
724`a` is an set.
620
725
621−Produces
726+#### Produces
622−--------
623
727
624An atom.
728An atom.
625
729
626−Source
730+#### Source
627−------
628
731
629 +- wyt :: size of set
732 +- wyt :: size of set
630 |- ^- @
733 |- ^- @
@@ -633,14 +736,13 @@ Source
633
736
634
737
635
738
636−Examples
739+#### Examples
637−--------
638
740
639− > =a (~(put in (~(put in (sa)) 'a')) 'b')
741+ > =a (~(put in (~(put in (sy)) 'a')) 'b')
640 > ~(wyt in a)
742 > ~(wyt in a)
641 2
743 2
642− > b
744+
643− {'bonita' 'madeleine' 'daniel' 'john'}
745+ > =b (sy `(list @t)`['john' 'bonita' 'daniel' 'madeleine' ~])
644 > ~(wyt in b)
746 > ~(wyt in b)
645 4
747 4
646
748