M
Mitch McBride
I have a problem who's solution requires functionality beyond what
Math::Combinatorics and other combinatorics modules offer. I need a
way of selecting combinations from different "buckets" that are
represented as nested arrays. For instance, the array @n = (['1','2'],
['a','b'],['y','z']) would return:
1 a y
2 a y
1 b y
2 b y
1 a z
2 a z
1 b z
2 b z
Math::Combinatorics prints the array reference when I try using nested
arrays. Anyone know of a module that can perform this type of
combination? Thanks!
#!/usr/bin/perl -w
use Math::Combinatorics;
my @n = (['1','2'],['a','b'],['y','z']);
print join("\n", map { join " ", @$_ } combine(3,@n)),"\n";
print "\n";
OUTPUT:
ARRAY(0x9ad0c28) ARRAY(0x9ae7b0c) ARRAY(0x9b94b50)
Math::Combinatorics and other combinatorics modules offer. I need a
way of selecting combinations from different "buckets" that are
represented as nested arrays. For instance, the array @n = (['1','2'],
['a','b'],['y','z']) would return:
1 a y
2 a y
1 b y
2 b y
1 a z
2 a z
1 b z
2 b z
Math::Combinatorics prints the array reference when I try using nested
arrays. Anyone know of a module that can perform this type of
combination? Thanks!
#!/usr/bin/perl -w
use Math::Combinatorics;
my @n = (['1','2'],['a','b'],['y','z']);
print join("\n", map { join " ", @$_ } combine(3,@n)),"\n";
print "\n";
OUTPUT:
ARRAY(0x9ad0c28) ARRAY(0x9ae7b0c) ARRAY(0x9b94b50)