Created
July 7, 2014 22:18
-
-
Save michaelochurch/4c910015a2e764eb8203 to your computer and use it in GitHub Desktop.
Another non-exploding use of Haskell's fix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Control.Monad.Fix | |
factorial :: Integer -> Integer | |
factorial = fix (\fct x -> if x == 0 then 1 else x * fct (x - 1)) | |
main :: IO () | |
main = putStrLn $ "5! = " ++ (show $ factorial 5) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment