Created
January 12, 2013 09:38
-
-
Save Javran/4516960 to your computer and use it in GitHub Desktop.
Y combinator in haskell
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
-- plz refer to http://stackoverflow.com/questions/4273413/y-combinator-in-haskell | |
newtype Mu a = Mu (Mu a -> a) | |
y f = (\h -> h $ Mu h) (\x -> f. (\(Mu g) -> g) x $ x) | |
fakePower self n = if n == 0 | |
then 1 | |
else n*self(n-1) | |
truePower = y fakePower | |
main = putStr $ show $ truePower 10 | |
-- output is '3628800' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment