Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
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 cooling their heels in the Monastery: (4)
As of 2016-06-25 10:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My preferred method of making French fries (chips) is in a ...











    Results (325 votes). Check out past polls.