Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- maybeFactorial :: Integer -> Maybe Integer
- maybeFactorial a
- | a < 0 = Nothing
- | otherwise = Just (doFactorial a)
- where
- doFactorial :: Integer -> Integer
- doFactorial x
- | x == 0 = 1
- | otherwise = x * (doFactorial (x - 1))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement