[Haskell-cafe] Random Number
iainspeed at gmail.com
Sun Jun 7 16:50:18 EDT 2009
On 7 Jun 2009, at 8:33 pm, ptrash wrote:
> is the are way (or a build in method) in haskell to get a random
> number from
> a number bottom to a number top?
> Something like
> let randomNumber = random 1 30
> to get a random number between 1 and 30.
rand :: Int -> Int -> IO Int
rand low high = getStdRandom (randomR (low,high))
this worked for me, I also had quite a few random questions on here a
few months ago! :)
Beware it is an IO int.
On 7 Jun 2009, at 8:55 pm, Krzysztof Skrzętnicki wrote:
> I don't mean to be rude, but did you even tried to read the
> documentation? The function you want is here:
> Before you ask any other questions please read this essay:
> Best regards
> Krzysztof Skrzętnicki
Bit harsh isn't it? He asked for an example function, not an entire
More information about the Haskell-Cafe