[Haskell-cafe] random shuffle and random list partition

Manlio Perillo manlio_perillo at libero.it
Fri Mar 20 20:18:11 EDT 2009


Yitzchak Gale ha scritto:
> Hi Manlio,
> 
> Manlio Perillo wrote:
>> For my Netflix Prize project I have implemented two reusable modules.
>> The first module implements a random shuffle on immutable lists...
>> The second module implements a function used to partition a list into n
>> sublists of random length.
> 
> [...]

> As you point out, your partition algorithm is not fair.
> Using your Random.Shuffle and a well-know trick
> from combinatorics, you can easily get a fair
> partitions function:
> 
> http://hpaste.org/fastcgi/hpaste.fcgi/view?id=2485#a2495
> 

Someone added an alternative implementation:
http://hpaste.org/fastcgi/hpaste.fcgi/view?id=2485#a2497


Regards  Manlio


More information about the Haskell-Cafe mailing list