Skip to content

Instantly share code, notes, and snippets.

@michaelochurch
Created July 7, 2014 22:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michaelochurch/4c910015a2e764eb8203 to your computer and use it in GitHub Desktop.
Save michaelochurch/4c910015a2e764eb8203 to your computer and use it in GitHub Desktop.
Another non-exploding use of Haskell's fix
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