<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;">There's still something screwy going on here with the random generation or passing the gen to cointoss. Shouldn't newStdGen be updating getStdGen?<br><br>I've been running it and entering 'h' four (4) times, then aborting with CNTL-C.<br>Each time I either get<br><br>You lose!<br>You lose!<br>You win!<br>You lose!<br><br>or<br><br>You win!<br>You win!<br>You lose!<br>You win!<br><br>That's all, should be getting some variation.<br><br>Michael<br><br>======================<br><br>import System.Random<br><br>coinToss :: StdGen -&gt; IO ()<br>coinToss gen = putStrLn "What's your guess, heads or tails ('h' or 't')?"<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &gt;&gt; fmap head getLine<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &gt;&gt;= \c -&gt; let (randInt, _) = randomR(0,1)
 gen :: (Int, StdGen)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; in if c == ((!!) "ht" randInt) then putStrLn "You win!" else putStrLn "You lose!"<br><br>main = do<br>&nbsp; gen &lt;- getStdGen<br>&nbsp; coinToss gen<br>&nbsp; gen &lt;- newStdGen<br>&nbsp; main<br><br><br>--- On <b>Sun, 10/11/09, Felipe Lessa <i>&lt;felipe.lessa@gmail.com&gt;</i></b> wrote:<br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"><br>From: Felipe Lessa &lt;felipe.lessa@gmail.com&gt;<br>Subject: Re: [Haskell-cafe] Simple program. Simple problem?<br>To: haskell-cafe@haskell.org<br>Date: Sunday, October 11, 2009, 7:08 PM<br><br><div class="plainMail">On Mon, Oct 12, 2009 at 12:42:16AM +0200, Peter Verswyvelen wrote:<br>&gt; btw I always find it amusing to play with interact and lazy IO:<br><br>I always find it frightening to
 play with lazy IO :).<br><br>--<br>Felipe.<br>_______________________________________________<br>Haskell-Cafe mailing list<br><a ymailto="mailto:Haskell-Cafe@haskell.org" href="/mc/compose?to=Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br><a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br></div></blockquote></td></tr></table><br>