Hi John,<br>When I was first encountered replicateM I found it really hard to understand. So,of course, I am audacious enough to assume that it is hard for you too! <br><br>The code suggested by Brent ,  &#39;replicateM 3 foo&#39; is a nicer way of writing the following:<br>
<br>foo = do<br>  x &lt;- getStdRandom $ randomR (1,10)<br>  y &lt;- getStdRandom $ randomR (1,10)<br>  z &lt;- getStdRandom $ randomR (1,10)<br>  return [x,y,z]<br><br>Hope this helped.<br>-deech<br><br><div class="gmail_quote">
On Sat, Oct 24, 2009 at 7:05 PM, Brent Yorgey <span dir="ltr">&lt;<a href="mailto:byorgey@seas.upenn.edu">byorgey@seas.upenn.edu</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div><div></div><div class="h5">On Sat, Oct 24, 2009 at 05:59:35PM +0100, John Moore wrote:<br>
&gt; Hi All,<br>
&gt;            Can anyone help me I want to produce a list of three random<br>
&gt; numbers for e.g. [7,8,1]<br>
&gt; I tried using x &lt;- getStdRandom $ randomR (1,10) but don&#39;t really understand<br>
&gt; this and it only generates one number. Any help greatly appreciated.<br>
<br>
</div></div>replicateM is your friend:<br>
<br>
  replicateM :: (Monad m) =&gt; Int -&gt; m a -&gt; m [a]<br>
<br>
so if &#39;foo&#39; produces a single random number, then &#39;replicateM 3 foo&#39;<br>
produces a list of three.<br>
<br>
-Brent<br>
_______________________________________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org">Beginners@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/beginners" target="_blank">http://www.haskell.org/mailman/listinfo/beginners</a><br>
</blockquote></div><br>