On Thu, 30 Apr 2009, MaurĂ­cio wrote:

import System.Random

rollDice :: IO Int
rollDice = getStdRandom (randomR (1,6))

rollNDice :: Int -> [IO Int]
rollNDice 0 = []
rollNDice n = rollDice : rollNDice (n-1)


replicateM n rollDice

http://www.haskell.org/haskellwiki/Avoiding_IO#State_monad

Or, if you want the original idea:

sequence (rollNDice 10)

Check the type of sequence at Control.Monad.

I'd still propose
  
http://www.haskell.org/haskellwiki/Haskell_programming_tips#Avoid_explicit_recursion
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to