[Haskell-cafe] Perfect shuffle on std. libs

Felipe Almeida Lessa felipe.lessa at gmail.com
Sat Jul 14 11:57:59 EDT 2007


Hello! =)

I wonder why Oleg's perfect shuffle[1] isn't on any standard library?
Is there a reason or is it just a lack of patches?

I'd personally like to have at least the function

> shuffle :: RandomGen g => g -> [a] -> [a]
> shuffle gen list =
>     let len = length list
>         ran = [r `mod` k | (k,r) <- zip [len,len-1..2] randoms gen]
>     in shuffle1 cartas rs'

where shuffle1 is Oleg's perfect shuffle and length is the
beSureYouReallyWantIntBeforeUsingThisLength ;).

Cheers,

[1] http://okmij.org/ftp/Haskell/perfect-shuffle.txt

-- 
Felipe.


More information about the Haskell-Cafe mailing list