random numbers
Derek Elkins
ddarius at hotpop.com
Fri Oct 24 04:41:39 EDT 2003
On Thu, 23 Oct 2003 23:01:30 -0700 (PDT)
Hal Daume III <hdaume at ISI.EDU> wrote:
> Hi!
>
> > 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.
The standard libraries are described in the Haskell Report.
www.haskell.org/libraries are -other- libraries written for/using
Haskell. I imagine most tutorials give at least a quick introduction to
the more useful libraries. ZVON.org is meant as a reference. You can
find a lists of tutorials and other learning material at
www.haskell.org/learning . The Report is also fairly readable including
the Random library documentation and an online version can be found at
www.haskell.org/onlinereport .
> 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
<unhelpful poor humor: ignore this>
Sherr it can return a random integer, it just has to always be the same
random integer.
</unhelpful poor humor>
More information about the Haskell-Cafe
mailing list