Created
October 15, 2016 21:11
-
-
Save alopatindev/4a4fddb983911c0a7c872e4720014eee to your computer and use it in GitHub Desktop.
Fibonacci numbers with Lambda Calculus
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
fix :: (a -> a) -> a | |
fix = \f -> f $ fix f | |
fib :: Int -> Int | |
fib = \n -> fix (\f n -> if n <= 2 then 1 else f (n - 2) + f (n - 1)) n | |
main = putStrLn $ show $ map fib [1..10] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
With Y-Combinator: