Need help

Nick Name nick.name@inwind.it
Tue, 23 Jul 2002 17:07:46 +0200


It's relatively simple.

The random number generator is a pure function, so it cannot be
nondeterministic. So, you have a way to build this function with a seed,
since the author wanted you to be able to do so, I could say for
completeness, or reuse sake.

But what you want is nondeterminism. How can you get that? With I/O of
course. So, apart from the fact I am not going to search the "getTime"
function, but it's probable haskell has one, and apart from the fact
that getTime is also nondeterministic, here's a program that prints a
true random number. Since this program uses I/O, it's a monadic action. 


import Random

main = 
    do a <- newStdGen
       print (head (randoms a) :: Float)

The correct initializator, as one can *suppose* (but not be sure) from
its type, is newStdGen.

Hope this helps

Vincenzo Ciancia