Beefy Boxes and Bandwidth Generously Provided by pair Networks Bob
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Is it possible to generate all possible combinations of 2-letter and 3-letter words in perl?

by Khen1950fx (Canon)
on Sep 02, 2012 at 16:31 UTC ( #991304=note: print w/ replies, xml ) Need Help??


in reply to Is it possible to generate all possible combinations of 2-letter and 3-letter words in perl?

Set::CrossProduct.

#!/usr/bin/perl use autodie; use common::sense; use Set::CrossProduct; my $min = 2; my $max = 3; my $set = [ qw(A T G C) ]; foreach my $length ( $min .. $max ) { say "Getting combinations of length $length"; my $cross = Set::CrossProduct->new( [ ( $set ) x $length ] ); while( my $tuple = $cross->get ) { say join '', @$tuple; } }


Comment on Re: Is it possible to generate all possible combinations of 2-letter and 3-letter words in perl?
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (8)
As of 2014-04-19 22:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (485 votes), past polls