Skip to content

Commit 6f747f3

Browse files
committed
talk about combinations and powerset for Set type
1 parent f1d0699 commit 6f747f3

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

S32-setting-library/Containers.pod

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,8 @@ array values. (Note: When used on actual sets and other iterable
586586
structures, specialized versions of this method are allowed to bypass
587587
turning it into a list first. Also, the return values are allowed
588588
to be specialized to any non-flattening container, so that subsets
589-
of sets can actually be a set of sets.)
589+
of sets can actually be a set of sets. If the ordering of the input
590+
doesn't matter, neither does the ordering of the subsets.)
590591

591592
It is erroneous to ask for the combinations of any infinite list.
592593
The compiler is allowed to complain if it notices, however.
@@ -1113,6 +1114,24 @@ Works like an ordinary list C<pick>.
11131114

11141115
Works like an ordinary list C<roll>.
11151116

1117+
=item combinations
1118+
1119+
multi method combinations ( Int $of )
1120+
multi method combinations ( Range $of = 1 .. +self )
1121+
1122+
Works as if the set were turned into a list of elements and then
1123+
the combinations were turned back into a list of sets, ordered by
1124+
increasing size. You may, of course, turn that list back into a set of sets.
1125+
1126+
Note that, without an argument, this method does not quite calculate
1127+
the powerset; you must add in the null set to get that, as below.
1128+
1129+
=item powerset
1130+
1131+
multi method powerset { set ∅, self.combinations }
1132+
1133+
Defined as above.
1134+
11161135
=back
11171136

11181137
=head2 KeySet

0 commit comments

Comments
 (0)