
14 Jul
2007
14 Jul
'07
11:57 a.m.
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.