On May 22, 2006, at 19:35, David Landgren wrote:
Kurt Starsinic wrote:
On 5/22/06, David Landgren <[EMAIL PROTECTED]> wrote:
I have a list of elements, qw[a b c d e] and I wanted to steal
some code
from CPAN to divvy it up into two subsets of 2 and 3 members. And
enumerate all the possibilities.
[ . . . . ]
Now my observation is that Set::Partition seems a little to generic
and/or I would be trampling on namespace with the proposed name. So
either do people have strong feelings about the name and/or a better
name for a module? Hint: When you read the subject of this
message, did
you have a pretty good idea of what this module does?
Or did I overlook a module that already does this?
Have you looked at Math::Combinatorics?
Well, apart from its abysmal documentation, no, not much. Nor does
the much better Algorithm::Combinatorics help here.
The difference is that an element doesn't permute within a set,
which cuts down on a lot of arrangements.
A cheap possibility (in terms of immediate effort) would be to base
the solution on combinations. That is, using for example
Algorithm::Combinatorics you iterate over all combinations of length
2 of qw(a b c d e). For each tuple, its complement is the
correponding triple in the partition.
That takes advantage of the fact that we want to divide a given set
in just two subsets of fixed size. A partitions generator may be
added to the module soon, but until then I think there's room for
Set::Partition.
-- fxn