Help for this page
## Filtering tye's "combinations" (power set) iterator: my $iter = combinations(@S); ... next unless @c == $K; ... }
## Using tye's Algorithm::Loops: NestedLoops( ... ( sub { [$_+1 .. $#S] } ) x ($K - 1), sub { my @c = @S[@_]; ... } }
sub combinations { my ($num, $arr) = @_; ... return @$arr[@pick]; }; }
my $iter = combinations( 3 => ['a' .. 'f'] ); while ( my @c = $iter->() ) { print "@c\n"; }
www.com | www.net | www.org
No recent polls found