Sorry if this is a really stupid question, but I already read one book and most of the other book about Haskell and I don't seem to remember that this was brought up.
How can I do the same n times? If you want to know exactly what I'm doing, I am trying to complete some questions from the Google Code Jam to learn Haskell, and the first line of input gives you the number of test cases. In this case, I need to do the same n times, where n is the number of test cases.
The only way I can do this so far is to write a recursive function as follows:
recFun :: Int -> IO () -> IO ()
recFun 0 f = do return ()
recFun n f = do
f
recFun (n-1) f
return ()
Is there a built-in function that already does this?
source
share