
13 Jun
2011
13 Jun
'11
8:27 p.m.
On Mon, Jun 13, 2011 at 4:56 PM, michael rice
Is there an (existing) way to select 5 Ints randomly (no duplicates) from a population, say 1-20 (inclusive)?
Michael
This is as close as I have gotten, but it is only probabilistically true. take_n_unique_randoms_in_range :: ( Ord random , Random random , MonadIO io ) => Int -> (random, random) -> io [random] take_n_unique_randoms_in_range n (a,b) = liftM ((take n) . nub) . (replicateM (3*n)) . liftIO $ randomRIO (a,b) I'm going to put making an iteratee-based solution on my agenda.