[racket-dev] How about adding this simple list-shuffling procedure to racket?
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