Last active
December 15, 2015 07:59
-
-
Save ir4y/5227953 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
@patterns | |
def factorial(): | |
with 0: 1 | |
with n: | |
if n is int: n * factorial(n-1) | |
if n is not int: raise ValueError("Int needed") | |
with []: [] | |
with [x] + xs: [factorial(x)] + factorial(xs) | |
with {'n': n, 'f': f}: f(factorial(n)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you want more complicated logic.