random numbers

Hal Daume III hdaume at ISI.EDU
Fri Oct 24 00:01:30 EDT 2003


> I'm very much a beginning programmer, studying Haskell. I have two
> questions -

Great!  Beginners are very welcome!

> Firstly, I am trying to generate random numbers in Haskell, but although I
> have found a 'random' library on www.zvon.org, I don't really know how to
> include library functions, and the documentation given doesn't really tell
> me the effective difference between all the functions provided in the
> library. In another interesting development, I couldn't find any mention
> of this library in haskell.org's list of libraries.

You want to put 'import Random' at the top of your program.  A bit of a 
warning, though: using random numbers isn't entirely straightforward in 
Haskell, due to the fact that it is a pure language (which means that you 
cannot have a function like 'randomInt :: () -> Int' which will return a 
random integer -- this is because any call to this function must always 
return the same result).

> Secondly, but perhaps more importantly, is there a more 'beginnerish' list
> that I should be addressing this to? I've been following discussions on
> this one and they don't seem to be at quite this level.

This list is appropriate.

 Hal Daume III                                   | hdaume at isi.edu
 "Arrest this man, he talks in maths."           | www.isi.edu/~hdaume

More information about the Haskell-Cafe mailing list