Created
January 17, 2013 02:14
-
-
Save alexlouden/4552918 to your computer and use it in GitHub Desktop.
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
def factorial(x): | |
result = 1 | |
for i in xrange(1, x + 1): | |
result *= i | |
return result | |
###################################################################### | |
def _if(test): | |
return lambda alternative: \ | |
lambda result: \ | |
[delay(result), delay(alternative)][not not test]() | |
def delay(f): | |
if callable(f): return f | |
else: return lambda: f | |
fact = lambda n: _if (n <= 1) (1) (lambda: n * fact(n-1)) | |
fact(100) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment