[Haskell-cafe] Acquiring a random set of a specific size (w/o dups) from a range of Ints

Felipe Almeida Lessa felipe.lessa at gmail.com
Thu Jun 16 20:18:41 CEST 2011


On Thu, Jun 16, 2011 at 3:04 PM, michael rice <nowgate at yahoo.com> wrote:
> I seem to still be missing some things. I found mt19937 in GSL.Random.Gen, but there are two evalMCs, one in Control.Monad.MC and another in Control.Monad.MC.GSL. Which?

Both are actually the same, because Control.Monad.MC reexports from
Control.Monad.MC.GSL. =)

GHCi, version 6.12.3: http://www.haskell.org/ghc/  :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Loading package ffi-1.0 ... linking ... done.
Prelude> :m + Control.Monad.MC
Prelude Control.Monad.MC> evalMC (sampleSubset [1..20] 5) (mt19937 0)
Loading package mtl-1.1.1.1 ... linking ... done.
Loading package primitive-0.3.1 ... linking ... done.
Loading package vector-0.7.0.1 ... linking ... done.
Loading package gsl-random-0.4.2 ... linking ... done.
Loading package monte-carlo-0.4.1 ... linking ... done.
[20,4,6,17,19]
Prelude Control.Monad.MC> evalMC (sampleSubset [1..20] 5) (mt19937 42)
[8,16,18,4,12]
Prelude Control.Monad.MC> evalMC (sampleSubset [1..20] 5) (mt19937 2938420)
[18,3,2,9,14]
Prelude Control.Monad.MC> evalMC (sampleSubset [1..20] 5) (mt19937 0)
[20,4,6,17,19]

Cheers,

--
Felipe.



More information about the Haskell-Cafe mailing list