<br><br><div class="gmail_quote">On Mon, Jun 13, 2011 at 4:56 PM, michael rice <span dir="ltr">&lt;<a href="mailto:nowgate@yahoo.com" target="_blank">nowgate@yahoo.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<table cellspacing="0" cellpadding="0" border="0"><tbody><tr><td valign="top" style="font:inherit"><div><font face="arial" size="2"><div>Is there an (existing) way to select 5 Ints randomly (no duplicates) from a population, say 1-20 (inclusive)?</div>

<div><br></div><font color="#888888"><div>Michael</div></font></font></div></td></tr></tbody></table></blockquote></div><br><div>This is as close as I have gotten, but it is only probabilistically true.</div>
<div><br></div><div><div>take_n_unique_randoms_in_range :: ( Ord random</div><div>                                  , Random random</div><div>                                  , MonadIO io</div><div>                                  ) =&gt; Int -&gt; (random, random) -&gt; io [random]</div>

<div>take_n_unique_randoms_in_range n (a,b) = liftM ((take n) . nub) . (replicateM (3*n)) . liftIO $ randomRIO (a,b) </div></div><div><br></div><div>I&#39;m going to put making an iteratee-based solution on my agenda.</div>