Subject: | Original array is emptied when doing full permutations |
Date: | Mon, 10 Sep 2018 11:49:52 -0700 |
To: | bug-Algorithm-Permute [...] rt.cpan.org |
From: | Bob Kleemann <rkleemann [...] gmail.com> |
When iterating over all possible permutations, there is a strange result
after the last permutation is complete:
perl -MAlgorithm::Permute -E '
my @elements = ( 1, 2, 3 );
for ( my $size = 1 ; $size <= scalar(@elements); $size++ ) {
say "size = $size";
my $p = Algorithm::Permute->new(\@elements, $size);
while ( my @list = $p->next ) {
say "[ ", join( ", ", @list ), " ]";
}
say scalar @elements, " = [ ", join( ", ", @elements ), " ]";
}
'
I would expect that @elements would be returned to the original content on
the completion of the for loop.