Last active
December 28, 2015 07:38
-
-
Save h2rd/7465358 to your computer and use it in GitHub Desktop.
function
This file contains hidden or 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 fabric(fnum): | |
| def add(num): | |
| return fnum + num | |
| return add | |
| def addition(num): | |
| return lambda x, num=num: x+num | |
| if __name__ == '__main__': | |
| add3 = fabric(3) | |
| assert add3(4), 7 | |
| assert add3(7), 10 | |
| assert add3(10), 13 | |
| add5 = addition(5) | |
| assert add5(4), 9 | |
| assert add5(7), 12 | |
| assert add5(10), 15 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment