[Haskell-beginners] randomize the order of a list

Felipe Lessa felipe.lessa at gmail.com
Sat Aug 28 10:38:49 EDT 2010

On Sat, Aug 28, 2010 at 10:49 AM, A Smith <asmith9983 at gmail.com> wrote:
> I've abeen recommended on good authority(my son, a Cambridge Pure maths
> graduate, and Perl/Haskell expert) , and backed by a Google search that
> Fisher-Yates shuffle is the  one to use, as it produces total unbiased
> results with every combination equally possible.
> As with most things with computers,don't reinvent the eheel, it's almost
> certainly been done before by someone brighter that you, Fisher,Yates. &
> Knuth!

That shuffle requires O(n) time and O(1) space for arrays.  Here we're
dealing with lists, so either you copy everything between lists and
array or use another algorithm.



More information about the Beginners mailing list