[Haskell-cafe] setting seed for random numbers

Bulat Ziganshin bulat.ziganshin at gmail.com
Sun Jan 3 13:24:20 EST 2010

Hello Larry,

Sunday, January 3, 2010, 8:46:30 PM, you wrote:

> Using "seed<-getSeed"  from the  ghci command line works. Why doesn't
> it work in a
> script?

because it's a feature of ghci command prompt, not haskell language.
use smth like this:

randList minval maxval = do
  seed  <-  getSeed
  return$ randomRs (minval,maxval) (mkStdGen seed)

of course, it will make randList non-pure function that may return
different results on different calls but that that you mean, no? ;)

Best regards,
 Bulat                            mailto:Bulat.Ziganshin at gmail.com

More information about the Haskell-Cafe mailing list