Skip to content

Commit 6fa36ad

Browse files
committed
nah, just default it to the powerset
Upon mature consideration, the powerset is the best default, if for no other reason than it will force some people to consider the degenerate case of 0 elements.
1 parent a3b902f commit 6fa36ad

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

S32-setting-library/Containers.pod

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,7 @@ C<.comb> on that string with the same parameters. See C<Str::comb>.
577577
=item combinations
578578

579579
multi method combinations ( Int $of )
580-
multi method combinations ( Range $of = 1 .. * )
580+
multi method combinations ( Range $of = 0 .. * )
581581

582582
Returns all combinations of the list taken N at a time (specified
583583
by the C<$of> parameter). If the range option is taken, returns all
@@ -591,6 +591,10 @@ container, so that subsets of sets can actually be a set of sets.
591591
If the ordering of the input doesn't matter, neither does the ordering
592592
of the subsets.)
593593

594+
Note that, without an argument, the first returned combination will
595+
always be the empty list, and the last combination will always
596+
be the entire list.
597+
594598
It is erroneous to ask for the combinations of any infinite list.
595599
The compiler is allowed to complain if it notices, however.
596600

@@ -1119,14 +1123,13 @@ Works like an ordinary list C<roll>.
11191123
=item combinations
11201124

11211125
multi method combinations ( Int $of )
1122-
multi method combinations ( Range $of = 1 .. * )
1126+
multi method combinations ( Range $of = 0 .. * )
11231127

11241128
Works as if the set were turned into a list of elements and then
11251129
the combinations were turned back into a list of sets, ordered by
11261130
increasing size. You may, of course, turn that list back into a set of sets.
11271131

1128-
Note that, without an argument, this method does not quite calculate
1129-
the powerset; you must explictly call with a range of 0..* for that.
1132+
Note that, without an argument, this method basically calculates the powerset.
11301133

11311134
=back
11321135

0 commit comments

Comments
 (0)