Skip to content

Commit 003331c

Browse files
author
Jan-Olof Hendig
committed
Added more examples
1 parent 4432ef3 commit 003331c

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

doc/Language/setbagmix.pod6

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,9 @@ X<Membership operator>.
102102
103103
Returns C<True> if C<$a> is an B<element> of C<$b>.
104104
105+
say 2 (elem) (1, 2, 3).Set; # OUTPUT: «True␤»
106+
say 4 (elem) (1, 2, 3).Set; # OUTPUT: «False␤»
107+
105108
=head4 infix ∈
106109
107110
only sub infix:<∈>($a, $b --> Bool)
@@ -119,6 +122,9 @@ X<Non-membership operator>.
119122
Equivalent to C<!(elem)>, i.e., returns C<True> if C<$a> is not an element
120123
of C<$b>, at codepoint U+2209 (NOT AN ELEMENT OF).
121124
125+
say 2 !(elem) (1, 2, 3).Set; # OUTPUT: «False␤»
126+
say 4 !(elem) (1, 2, 3).Set; # OUTPUT: «True␤»
127+
122128
=head3 infix (cont)
123129
124130
multi sub infix:<(cont)>(Any $a, $b --> Bool)
@@ -128,6 +134,9 @@ X<Contains operator>.
128134
129135
Returns C<True> if C<$a> B<contains> C<$b> as an element.
130136
137+
say (1, 2, 3).Set (cont) 2; # OUTPUT: «True␤»
138+
say (1, 2, 3).Set (cont) 4; # OUTPUT: «False␤»
139+
131140
=head4 infix ∋
132141
133142
only sub infix:<∋>($a, $b --> Bool)
@@ -145,6 +154,9 @@ X<Does not contain operator>.
145154
Equivalent to C<!(cont)>, i.e., returns C<True> if C<$a> does not contain
146155
C<$b>, at codepoint U+220C (DOES NOT CONTAIN AS MEMBER).
147156
157+
say (1, 2, 3).Set !(cont) 2; # OUTPUT: «False␤»
158+
say (1, 2, 3).Set !(cont) 4; # OUTPUT: «True␤»
159+
148160
=head3 infix (<=)
149161
150162
multi sub infix:<<(<=)>>(Any $a, Any $b --> Bool)
@@ -156,6 +168,10 @@ Returns C<True> if C<$a> is a B<subset> or is equal to C<$b>, i.e., if all
156168
the elements of C<$a> are elements of C<$b> and C<$a> is a smaller or equal
157169
sized set than C<$b>.
158170
171+
say (1, 2, 3).Set (<=) (3, 2, 1).Set; # OUTPUT: «True␤»
172+
say (1, 3).Set (<=) (2, 1).Set; # OUTPUT: «False␤»
173+
say ∅ (<=) (3, 2, 1).Set; # OUTPUT: «True␤»
174+
159175
=head4 infix ⊆
160176
161177
only sub infix:<⊆>($a, $b --> Bool)
@@ -172,6 +188,9 @@ X<Neither subset of nor equal to operator>.
172188
173189
Equivalent to C«!(<=)», at codepoint U+2288 (NEITHER A SUBSET OF NOR EQUAL TO).
174190
191+
say (1, 2, 3).Set !(<=) (3, 2, 1).Set; # OUTPUT: «False␤»
192+
say (1, 3).Set ⊈ (2, 1).Set; # OUTPUT: «True␤»
193+
175194
=head3 infix (<)
176195
177196
multi sub infix:<<(<)>>(Any $a, Any $b --> Bool)
@@ -183,6 +202,10 @@ Returns C<True> if C<$a> is a B<strict subset> of C<$b>, i.e., that all the
183202
elements of C<$a> are elements of C<$b> but C<$a> is a smaller set than
184203
C<$b>.
185204
205+
say (1, 2, 3).Set (<) (3, 2, 1).Set; # OUTPUT: «False␤»
206+
say (1, 3).Set (<) (3, 2, 1).Set; # OUTPUT: «True␤»
207+
say ∅ (<) (3, 2, 1).Set; # OUTPUT: «True␤»
208+
186209
=head4 infix ⊂
187210
188211
only sub infix:<⊂>($a, $b --> Bool)
@@ -199,6 +222,9 @@ X<Not a subset of operator>.
199222
200223
Equivalent to C«!(<)», at codepoint U+2284 (NOT A SUBSET OF).
201224
225+
say (1, 2, 3).Set !(<) (3, 2, 1).Set; # OUTPUT: «True␤»
226+
say (1, 3).Set ⊄ (3, 2, 1).Set; # OUTPUT: «False␤»
227+
202228
=head3 infix (>=)
203229
204230
multi sub infix:<<(>=)>>(Any $a, Any $b --> Bool)
@@ -209,6 +235,10 @@ X<Superset of or equal to operator>.
209235
Like L«(<=)» with reversed arguments. Returns C<True> if C<$a> is a
210236
B<superset> of or equal to C<$b>.
211237
238+
say (1, 2, 3).Set (>=) (3, 2, 1).Set; # OUTPUT: «True␤»
239+
say (1, 3).Set (>=) (3, 2, 1).Set; # OUTPUT: «False␤»
240+
say ∅ (>=) (3, 2, 1).Set; # OUTPUT: «False␤»
241+
212242
=head4 infix ⊇
213243
214244
only sub infix:<⊇>($a, $b --> Bool)
@@ -226,6 +256,9 @@ X<Neither a superset of nor equal to operator>.
226256
Equivalent to C«!(>=)», at codepoint U+2289 (NEITHER A SUPERSET OF
227257
NOR EQUAL TO).
228258
259+
say (1, 2, 3).Set !(>=) (3, 2, 1).Set; # OUTPUT: «False␤»
260+
say (1, 3).Set ⊉ (3, 2, 1).Set; # OUTPUT: «True␤»
261+
229262
=head3 infix (>)
230263
231264
multi sub infix:<<(>)>>(Any $a, Any $b --> Bool)
@@ -236,6 +269,10 @@ X<Superset of operator>.
236269
Like L«(<)» with reversed arguments. Returns C<True> if C<$a> is a
237270
B<strict superset> of C<$b>.
238271
272+
say (1, 2, 3, 4).Set (>) (3, 2, 1).Set; # OUTPUT: «True␤»
273+
say (1, 3).Set (>) (3, 2, 1).Set; # OUTPUT: «False␤»
274+
say ∅ (>) (3, 2, 1).Set; # OUTPUT: «False␤»
275+
239276
=head4 infix ⊃
240277
241278
only sub infix:<⊃>($a, $b --> Bool)
@@ -252,6 +289,9 @@ X<Not a superset of operator>.
252289
253290
Equivalent to C«!(>)», at codepoint U+2285 (NOT A SUPERSET OF).
254291
292+
say (1, 2, 3, 4).Set !(>) (3, 2, 1).Set; # OUTPUT: «False␤»
293+
say (1, 3).Set ⊅ (3, 2, 1).Set; # OUTPUT: «True␤»
294+
255295
=head3 infix (<+)
256296
257297
multi sub infix:<<(<+)>>(Any $a, Any $b --> Bool)
@@ -263,6 +303,9 @@ Returns C<True> if C<$a> is a Baggy B<subset> of C<$b>, i.e., if all the
263303
elements of C<$a> are in C<$b> and each element of C<$b> is weighed at
264304
least as heavily as the element is in C<$a>.
265305
306+
say (1, 2, 3).Bag (<+) (3, 2, 1).Bag; # OUTPUT: «True␤»
307+
say (1, 2, 2, 3).Bag (<+) (3, 2, 1).Bag; # OUTPUT: «False␤»
308+
266309
=head4 infix ≼
267310
268311
only sub infix:<≼>($a, $b --> Bool)
@@ -282,6 +325,10 @@ Returns C<True> if C<$a> is a Baggy B<superset> of C<$b>, i.e., if all the
282325
elements of C<$b> are in C<$a> and no element of C<$b> is weighted heavier
283326
than that element is in C<$a>.
284327
328+
say (1, 2, 3).Bag (>+) (3, 2, 1).Bag; # OUTPUT: «True␤»
329+
say (1, 2, 2, 3).Bag (>+) (3, 2, 1).Bag; # OUTPUT: «True␤»
330+
say (1, 2).Bag (>+) (3, 2, 1).Bag; # OUTPUT: «False␤»
331+
285332
=head4 infix ≽
286333
287334
only sub infix:<≽>($a, $b --> Bool)

0 commit comments

Comments
 (0)