[Haskell-beginners] Re: [Haskell-cafe] Re: permuting a list
Heinrich Apfelmus
apfelmus at quantentunnel.de
Mon Feb 16 03:41:50 EST 2009
Alberto Ruiz wrote:
>
> How about using random doubles?
>
> randomPerm xs = fmap (map snd . sort . flip zip xs) rs
> where rs = fmap (randoms . mkStdGen) randomIO :: IO [Double]
Interesting idea. The chance of duplicates should be negligible now, but
that's because we're using a large amount of random bits, far more than
n! would require.
Regards,
apfelmus
--
http://apfelmus.nfshost.com
More information about the Beginners
mailing list