Math::Combinatorics

Math::Combinatorics is a Perl module that can perform combinations and permutations on lists.
Download

Math::Combinatorics Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Allen Day
  • Publisher web site:
  • http://search.cpan.org/~birney/bioperl-1.4/Bio/DB/GFF/Aggregator/ucsc_genscan.pm

Math::Combinatorics Tags


Math::Combinatorics Description

Math::Combinatorics is a Perl module that can perform combinations and permutations on lists. Math::Combinatorics is a Perl module that can perform combinations and permutations on lists.SYNOPSISAvailable as an object oriented API. use Math::Combinatorics; my @n = qw(a b c); my $combinat = Math::Combinatorics->new(count => 2, data => , ); print "combinations of 2 from: ".join(" ",@n)."n"; print "------------------------".("--" x scalar(@n))."n"; while(my @combo = $combinat->next_combination){ print join(' ', @combo)."n"; } print "n"; print "permutations of 3 from: ".join(" ",@n)."n"; print "------------------------".("--" x scalar(@n))."n"; while(my @permu = $combinat->next_permutation){ print join(' ', @permu)."n"; } output:Or available via exported functions 'permute', 'combine', and 'factorial'. use Math::Combinatorics; my @n = qw(a b c); print "combinations of 2 from: ".join(" ",@n)."n"; print "------------------------".("--" x scalar(@n))."n"; print join("n", map { join " ", @$_ } combine(2,@n)),"n"; print "n"; print "permutations of 3 from: ".join(" ",@n)."n"; print "------------------------".("--" x scalar(@n))."n"; print join("n", map { join " ", @$_ } permute(@n)),"n";Output: combinations of 2 from: a b c ------------------------------ a b a c b c permutations of 3 from: a b c ------------------------------ a b c a c b b a c b c a c a b c b aOutput from both types of calls is the same, but the object-oriented approach consumes much less memory for large sets. Requirements: · Perl


Math::Combinatorics Related Software