in reply to Combinatorics of Math::Combinatorics

I would use Algorithm::Combinatorics.
#!/usr/bin/perl -l BEGIN { $| = 1; $^W = 1; } use strict; use warnings; use Data::Dump qw(pp); use Algorithm::Combinatorics qw(partitions); my(@data) = qw(a b c d e f g); my $iter = partitions(\@data, 3, 4); while (my $p = $iter->next) { print pp($p); }

Replies are listed 'Best First'.
Re^2: Combinatorics of Math::Combinatorics (usage)
by tye (Sage) on Jul 21, 2012 at 20:26 UTC

    From the documentation that you linked to, calling partitions( \@data, 3, 4 ) is not a supported usage. Reading the code linked from there, it appears to be the same as calling partitions( \@data, 3 ) which would produce only partitions composed of exactly 3 subsets, not partitions of any size but with no more than 3 members in each subset of the partition (the latter being what, to me, the OP seems to have asked for).

    - tye