I need some random numbers.

in the IO Monad, hiding the use of a generator

do x <- randomRIO (0, 1 :: Double) ; print x

you can also make the state explicit:

do g0 <- getStdGen ; let { ( x, g1 ) = randomR ( 0, 1::Double) g0 } ;
   print x

a RandomGen is actually the state object for the generator,
much like  http://java.sun.com/javase/6/docs/api/java/util/Random.html

best regards, J.W.


_______________________________________________
Haskell mailing list
Haskell@haskell.org
http://www.haskell.org/mailman/listinfo/haskell

Reply via email to