On Wed, Sep 24, 2008 at 2:03 PM, Iain Barnett <[EMAIL PROTECTED]> wrote:
> 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.
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to