<DIV>Thanks Stefan,</DIV>
<DIV>&nbsp;</DIV>
<DIV>Sorry for sending the message to the bug list. My first post to</DIV>
<DIV>the users mailing list seems to get lost somewhere.&nbsp; I therefore try </DIV>
<DIV>my luck on the bug list. It seems to work :)</DIV>
<DIV>&nbsp;</DIV>
<DIV>I am extending my polyGP system using the new haskell compiler.</DIV>
<DIV>The random number is to be used for selecting crossover/mutation </DIV>
<DIV>points, not to be printed (not IO type). I tried the following and they</DIV>
<DIV>seem to work fine. </DIV>
<DIV>&nbsp;</DIV>
<DIV>-- get a list of random int between 1 and 250</DIV>
<DIV>drawInt :: [Int]<BR>drawInt = randomRs (1, 250)(mkStdGen 10)<BR></DIV>
<DIV>-- get a list&nbsp;of random double between 0 and 100&nbsp;&nbsp; <BR>drawDouble :: [Double]<BR>drawDouble = randomRs (0, 100) (mkStdGen 100)<BR></DIV>
<DIV>Are they really random numbers ? I am wodering why all</DIV>
<DIV>random double has values &lt; 1.0. Do you know ? Thanks !!</DIV>
<DIV>&nbsp;</DIV>
<DIV>Tina<BR><B><I>Stefan Reich &lt;doc@drjava.de&gt;</I></B> wrote:</DIV>
<BLOCKQUOTE class=replbq style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #1010ff 2px solid">That's definitely not a message for the bugs list :-)<BR><BR>Please have a look at this page: <BR>http://www.zvon.org/other/haskell/Outputrandom/getStdRandom_f.html<BR><BR>It gives the correct signature for drawInt as you defined it: Int -&gt; Int <BR>-&gt; IO Int<BR><BR>The signature you gave doesn't work because it specifies a pure function <BR>- for the same set of arguments, it must always produce the same result.<BR><BR>How many ints do you want to generate? I don't think it is possible to <BR>generate an infinite lazy list in this case because this interferes with <BR>monad semantics. If you want a fixed number of random ints, try this:<BR><BR>drawInts :: Int -&gt; Int -&gt; Int -&gt; IO [Int]<BR>drawInts num x y = sequence (replicate num (getStdRandom (randomR (x,y))))<BR><BR>-Stefan<BR><BR>Gwoing Yu wrote:<BR><BR>&gt; Hi,<BR>&gt; <BR>&gt; I need some assistances in calling
 random number generator using 6.0.1 <BR>&gt; haskell compiler. To return a list of random int [Int], I have tried <BR>&gt; the following:<BR>&gt; <BR>&gt; drawInt :: Int-&gt;Int -&gt; [Int]<BR>&gt; drawInt x y = getStdRandom (randomRs (x,y))<BR>&gt; <BR>&gt; It has a type error. I would appreciate if you know how to fix it.<BR>&gt; <BR>&gt; Thank you in advance.<BR>&gt; <BR>&gt; Tina Yu<BR>&gt; http://www.improvise.ws <HTTP: www.improvise.ws /><BR></BLOCKQUOTE><p><hr SIZE=1>
Do you Yahoo!?<br>
Yahoo! Hotjobs: <a href="http://pa.yahoo.com/*http://us.rd.yahoo.com/hotjobs/mail_footer_email/evt=21482/*http://hotjobs.sweepstakes.yahoo.com/signingbonus">Enter the "Signing Bonus" Sweepstakes</a>