Skip Menu |

This queue is for tickets about the Math-Combinatorics CPAN distribution.

Report information
The Basics
Id: 74455
Status: new
Priority: 0/
Queue: Math-Combinatorics

People
Owner: Nobody in particular
Requestors: MTHURN [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Critical
Broken in: 0.09
Fixed in: (no value)



Subject: next_permutation() returns same thing many times
The permutation code seems to be completely broken. The sample input of three strings (A B C) for a count of 2 works, but any longer list results in massively redundant output. For (A B C D) it returns every pair twice; for (A B C D E) it returns every pair SIX times!?! Try this code: use Math::Combinatorics; my @as = qw( A B C D E ); my $ras = \@as; my $oPermuter = new Math::Combinatorics( compare => sub { $_[0] cmp $_[1] }, count => 2, data => $ras, ); PERMUTATION: while (my ($sWord1, $sWord2) = $oPermuter->next_permutation) { print STDERR " DDD permutation is ==$sWord1==$sWord2==\n"; } # while __END__