Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

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 ( [id://1117908]=note: print w/replies, xml ) Need Help??


in reply to Re^2: 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

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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1117908]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (3)
As of 2024-04-19 19:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found