Algorithm-Loops
view release on metacpan or search on metacpan
lib/Algorithm/Loops.pm view on Meta::CPAN
Algorithm::Permute also includes some fun benchmarks comparing different
Perl ways of finding permutations. I found NextPermute to be faster than
any of the routines included in those benchmarks except for the ones
written in C that I mentioned above. Though none of the benchmarked
routines deal with duplicates.
=back
=head3 Notes
Note that NextPermute() considers two values (say $x and $y) to be
duplicates if (and only if) C<$x eq $y>.
NextPermuteNum() considers $x and $y to be duplicates if C<$x == $y>.
If you have a list of floating point numbers to permute, you might want
to use NextPermute() [instead of NextPermuteNum()] as it is easy to end
up with $x and $y that both display the same (say as "0.1") but are
B<just barely> not equal numerically. Thus $x and $y would I<look> equal
and it would be true that C<$x eq $y> but also true that C<$x != $y>. So
NextPermute() would consider them to be duplicates but NextPermuteNum()
would not.
For example, $x could be slightly more than 1/10, likely about
0.1000000000000000056, while $y is slightly more at about
0.0999999999999999917 (both of which will be displayed as "0.1" by Perl
and be considered C<eq> (on most platforms):
( run in 0.339 second using v1.01-cache-2.11-cpan-483215c6ad5 )