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

2010-11-12 Thread Jay McCarthy
I think we should put in a list shuffler into the core. Which should we use? The faster one? Jay On Thu, Nov 11, 2010 at 11:26 AM, Eli Barzilay e...@barzilay.org wrote: 5 minutes ago, Neil Toronto wrote: Carl Eastlund wrote: It's pick a random, uniform ordering, and then sort based on it.

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

2010-11-12 Thread Robby Findler
I think we want the one recommended by the statisticians. :) Robby On Fri, Nov 12, 2010 at 2:36 PM, Jay McCarthy jay.mccar...@gmail.com wrote: I think we should put in a list shuffler into the core. Which should we use? The faster one? Jay On Thu, Nov 11, 2010 at 11:26 AM, Eli Barzilay

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

2010-11-12 Thread Eli Barzilay
Any objections to `shuffle' in `racket/list'? -- ((lambda (x) (x x)) (lambda (x) (x x))) Eli Barzilay: http://barzilay.org/ Maze is Life! _ For list-related administrative tasks:

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

2010-11-12 Thread Jay McCarthy
Not by me. On Fri, Nov 12, 2010 at 2:25 PM, Eli Barzilay e...@barzilay.org wrote: Any objections to `shuffle' in `racket/list'? --          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:                    http://barzilay.org/                   Maze is Life!

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

2010-11-11 Thread Eric Hanchrow
I find myself using this all the time; it seems it'd be handy to have built in. (define (shuffled list) (sort list #:key (lambda (_) (random)) #:cache-keys? #t)) Thanks. _ For list-related administrative tasks:

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

2010-11-11 Thread Neil Toronto
Eric Hanchrow wrote: I find myself using this all the time; it seems it'd be handy to have built in. (define (shuffled list) (sort list #:key (lambda (_) (random)) #:cache-keys? #t)) Is the distribution of shuffled lists uniform? That'd be hard to analyze, since it would depend on the

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

2010-11-11 Thread Carl Eastlund
On Thu, Nov 11, 2010 at 12:18 PM, Neil Toronto neil.toro...@gmail.com wrote: Eric Hanchrow wrote: I find myself using this all the time; it seems it'd be handy to have built in. (define (shuffled list)  (sort list #:key (lambda (_) (random)) #:cache-keys? #t)) Is the distribution of

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

2010-11-11 Thread Robby Findler
I think that if random doesn't pick the same number twice you're guaranteed to be independent of the sorting algorithm, at least. Robby On Thu, Nov 11, 2010 at 11:18 AM, Neil Toronto neil.toro...@gmail.com wrote: Eric Hanchrow wrote: I find myself using this all the time; it seems it'd be

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

2010-11-11 Thread Carl Eastlund
On Thu, Nov 11, 2010 at 12:40 PM, Neil Toronto neil.toro...@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

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

2010-11-11 Thread Robby Findler
On Thu, Nov 11, 2010 at 11:40 AM, Carl Eastlund c...@ccs.neu.edu wrote: On Thu, Nov 11, 2010 at 12:40 PM, Neil Toronto neil.toro...@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

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

2010-11-11 Thread Eli Barzilay
5 minutes ago, Neil Toronto wrote: Carl Eastlund wrote: 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. Spanking good point, my good man. I think you're right. It's a very

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

2010-11-11 Thread Jos Koot
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)