Haskell and functional programming is something I am not familiar with, and this semester I got to meet Haskell for the very 1st time. I got unlimited loop when I tried to do a recursion (not very proud of it)
Here's the code
import Data.List
import System.IO
mrLoop :: Int -> Int -> IO()
mrLoop a b = do
if b == 10 then return ()
else
print(a*b)
mrLoop a (b+1)
main = do mrLoop 2 0
So I tried to play with it and somehow it works
mrLoop :: Int -> Int -> IO()
mrLoop a 10 = return()
mrLoop a b = do
print(a*b)
mrLoop a (b+1)
But a friend of mine says that's not the Haskell way. So how do I do it in an Haskell way? And why the 1st code doesn't work?