
24 Sep
2008
24 Sep
'08
5:13 p.m.
On Wed, Sep 24, 2008 at 2:03 PM, Iain Barnett
Hi,
I have a function, that produces a random number between two given numbers
rand :: Int -> Int -> IO Int rand low high = getStdRandom (randomR (low,high))
(Naively) I'd like to write something like
take (rand 1 10 ) [1..10]
So once you apply those two Ints, the type of the expression is no longer a function, it's (IO Int), which is an action that produces and Int. So you want to do the action 10 times. For one approach, check out 'replicate' to make copies of something, and then 'sequence' to run them and return a list.