![]() |
|
good chemistry is complicated, and a little bit messy -LW |
|
PerlMonks |
Re: Random but non-repeating array loopby sifukurt (Hermit) |
on Jan 18, 2002 at 23:05 UTC ( #139915=note: print w/replies, xml ) | Need Help?? |
As japhy suggests, the Fisher-Yates shuffle is a good solution. If you want to save yourself the trouble of coding it, I've got it implemented in Math::NumberCruncher. Math::NumberCruncher also has numerous other similar functions that may be useful. Using Math::NumberCruncher, you could do the above like so:
UPDATE: Pursuant to Juerd's post, in the interest of TMTOWTDI, here's the code using Math::NumberCruncher through its original functional interface:
___________________ Kurt
In Section
Seekers of Perl Wisdom
|
|