Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- factorial :: Int -> Int
- factorial num
- | num == 0 = 1
- | otherwise = num * factorial (num-1)
- -- this is deferred operation or something, answer not evaluated until the recursion starts unwinding?:
- factorial2 :: Int -> Int
- factorial2 n = help n 1
- help :: Int -> Int -> Int
- help n m
- | n == 0 = m
- | otherwise = help (n - 1) (m * n)
Advertisement
Add Comment
Please, Sign In to add comment