-
-
Save abersheeran/80709d4ffd7e83c1206dbcc8df11d4d5 to your computer and use it in GitHub Desktop.
Y combinator. Python lambda.
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
Y = lambda g: (lambda f: g(lambda arg: f(f)(arg))) (lambda f: g(lambda arg: f(f)(arg))) | |
if __name__ == "__main__": | |
fib = Y(lambda f: lambda n: (1 if n < 3 else f(n-1) + f(n-2))) | |
print(fib(10)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment