Subject: | Mutliple calls to new (??) break it in some instances |
For some reason, in SOME cases, iterating over multiple permutations
fails. I ran into a case where it failed, and I've got it down to a very
simple case. It fails on multiple OSes (linux and solaris), multiple
versions of perl (5.8.7 and 5.8.8), and multiple architectures (x86,
x86_64, and sparc). It also failes under multiple versions of
Algorithm-Permute (0.08-0.11).
Here's a simple test script:
###################################################################
#!/usr/bin/perl -w
use Algorithm::Permute;
sub perm {
print "Permute...\n";
my($p)= new Algorithm::Permute([0..2],2);
for (my $i = 0; $i<6; $i++) {
my(@idx) = $p->next;
print " "x3,join(" ",@idx),"\n";
}
}
perm;
perm;
###################################################################
and the output is:
###################################################################
Permute...
1 0
0 1
2 1
1 2
2 0
0 2
Permute...
1 0
0 1
2 1
1 2
###################################################################
So, the second time I permute, I only find 4 of the 6 possible permutations.
Let me know if there is any other information you can use. Hopefully
this can be resolved since I'm writing something which relies on
permutations, and I don't want to roll my own!