Looking around for a shuffle routine I found this thread and the ensuing discussion amongst others.
Playing with this I came up with this:
This one-liner satisfies my (loose) criteria for a shuffle but I got to wondering if it would pass as a Fisher-Yates shuffle? Unfortunately, my math isn't sufficient to determine this. Anyone else have an opinion or suggest an appropriate method for testing its randomness?my @values; @values = (1..1000); @values[$_,$a] = @values[$a=rand($_-1),$_] for (reverse 1..$#values);
In reply to Fisher-Yates shuffle? by BrowserUk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |