[racket] Knuth's algorithm S

From: Sean Kanaley (skanaley at gmail.com)
Date: Mon Mar 10 15:09:28 EDT 2014

The current Racket algorithm has an error:

(define counts (build-vector 10 identity))

This sets the counts to their indices, meaning e.g. 9 was pre-counted 9
times.  Switch the first line of the executable portion to run only say 3
trials to see the effects.  It should be:

(define counts (make-vector 10))

Also, multiplying count by (random) should just be (random count):

(when (< (* count (random)) n)
              (vector-set! vec (random n) item))))

becomes

(when (< (random count) n)
              (vector-set! vec (random n) item))))




On Mon, Mar 10, 2014 at 2:19 AM, Manfred Lotz <manfred.lotz at arcor.de> wrote:

> Justfor the records: I updated the version at
>   http://rosettacode.org/wiki/Knuth%27s_algorithm_S#Racket
>
> --
> Manfred
>
>
> ____________________
>   Racket Users list:
>   http://lists.racket-lang.org/users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20140310/2c6bff3b/attachment.html>

Posted on the users mailing list.