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

From: Jos Koot (jos.koot at telefonica.net)
Date: Thu Nov 11 13:39:57 EST 2010

 
When truly picking uniformally shuffled lists from a given list, see:

http://telefonica.net/web2/koot/natural-to-permutation.scm

and try

(require srfi/27) ; for random-integer
(require "natural-to-permutation.scm")

(let*
    ((lst (build-list 1000 (lambda (k) (round (quotient k 10)))))
     (shuffler (make-K->P lst eq?))
     (K (random-integer (nPs lst eq?))))
  (time (shuffler K)))

Where random-integer is assumed to produce a uniform distribution.

Jos






Posted on the dev mailing list.