On Mon, Jun 13, 2011 at 8:56 PM, michael rice <[email protected]> wrote:
> Is there an (existing) way to select 5 Ints randomly (no duplicates) from a 
> population, say 1-20 (inclusive)?

Yes, already implemented in the monte-carlo package as sampleSubset [1],

  sampleSubset :: MonadMC m => [a] -> Int -> m [a]

Complete example code for your example:

  evalMC (sampleSubset [1..20] 5) (mt19937 0)

Cheers!

[1] 
http://hackage.haskell.org/packages/archive/monte-carlo/0.4.1/doc/html/Control-Monad-MC-Class.html#v:sampleSubset

--
Felipe.

_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to