[racket-dev] How about adding this simple list-shuffling procedure to racket?

From: Robby Findler (robby at eecs.northwestern.edu)
Date: Thu Nov 11 12:42:51 EST 2010

On Thu, Nov 11, 2010 at 11:40 AM, Carl Eastlund <cce at ccs.neu.edu> wrote:
> On Thu, Nov 11, 2010 at 12:40 PM, Neil Toronto <neil.toronto at gmail.com> wrote:
>>
>> I don't know. I know that the "run through the list and swap with another
>> random element" algorithms are usually non-uniform, and so are a lot of
>> other things that seem like they'd work. I wouldn't use something that
>> wasn't proven to shuffle uniformly, at least for any serious statistics
>> work.
>
> But this is not "run through the list and swap with another random
> element".  It's "pick a random, uniform ordering, and then sort based
> on it".  The random keys are chosen per element and cached (hence
> #:cache-keys? #t), not per comparison.

Note that this is not the algorithm at the other end of the link that
Neil T. sent; but one could probably make one like it in a simple
manner using this idea.

Robby


Posted on the dev mailing list.