の要素から組み合わせを作成しますように私はすべての可能な組み合わせを形成し、配列の配列を作成したい私は以下のような配列参照持つ配列
my $strings = [qw(a b c d)];
を:
私が試した何my $output = [qw(qw([a],[b],[c],[d],[a,b],[a,c],[a,d],[b,c],[b,d],[c,d], [a,b,c],[a,b,d],[b,c,d],[a,b,c,d]))]
:
foreach my $n(1..scalar(@array)) {
my $iter = combinations($strings, $n);
while (my $c = $iter->next) {
print "@$c\n";
}
}
これを確認してください:http://search.cpan.org/~ allenday/Math-Combinatorics-0.09/lib/Math/Combinatorics.pm#combine() – yonyon100