in reply to CPAN module to return successive combinations of n things taken k at a time

Hello ibm1620,

Another option: Math::Combinatorics:

#! perl use strict; use warnings; use Math::Combinatorics; my @n = qw(a e i o u); my $com = Math::Combinatorics->new ( count => 2, data => [@n], ); my $s = join(' ', @n); print '-' x (24 + length $s), "\n"; print "Combinations of 2 from: $s\n"; print '-' x (24 + length $s), "\n"; while (my @combo = $com->next_combination) { print join(' ', @combo), "\n"; }

(Code adapted from the documentation.)

Hope that helps,

Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,

  • Comment on Re: CPAN module to return successive combinations of n things taken k at a time
  • Download Code