Skip to content

Commit

Permalink
nah, just default it to the powerset
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
TimToady committed Feb 17, 2013
1 parent a3b902f commit 6fa36ad
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions S32-setting-library/Containers.pod
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ C<.comb> on that string with the same parameters. See C<Str::comb>.
=item combinations

multi method combinations ( Int $of )
multi method combinations ( Range $of = 1 .. * )
multi method combinations ( Range $of = 0 .. * )

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

Note that, without an argument, the first returned combination will
always be the empty list, and the last combination will always
be the entire list.

It is erroneous to ask for the combinations of any infinite list.
The compiler is allowed to complain if it notices, however.

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

multi method combinations ( Int $of )
multi method combinations ( Range $of = 1 .. * )
multi method combinations ( Range $of = 0 .. * )

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

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

=back

Expand Down

0 comments on commit 6fa36ad

Please sign in to comment.