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

Actually, Charlie, I did look, but I ended up in a mathematics section that was completely over my head. Neither the word "permutations" nor "iterator" occurred to me. But thanks for the link.
  • Comment on Re^2: CPAN module to return successive combinations of n things taken k at a time

Replies are listed 'Best First'.
Re^3: CPAN module to return successive combinations of n things taken k at a time
by ibm1620 (Hermit) on Feb 26, 2015 at 04:41 UTC
    For the record:
    #!/usr/bin/env perl use strict; use warnings; use 5.010; use Algorithm::Combinatorics qw(combinations); my @data = qw(a b c d e); # scalar context gives an iterator my $iter = combinations(\@data, 3); while (my $p = $iter->next) { say (join '', @$p); }
    Produces:
    abc abd abe acd ace ade bcd bce bde cde
    As required.
Re^3: CPAN module to return successive combinations of n things taken k at a time
by LanX (Saint) on Feb 26, 2015 at 04:28 UTC
    > Neither the word "permutations" nor "iterator" occurred to me.

    Dear Bill, please see my update.

    The results are even better. :)

    Cheers Rolf
    (addicted to the Perl Programming Language and ☆☆☆☆ :)

    PS: Je suis Charlie!