Last active
August 29, 2015 14:22
-
-
Save justinfay/aacb055415339570a931 to your computer and use it in GitHub Desktop.
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 counter(): | |
| ... def wrapper(): | |
| ... wrapper.count += 1 | |
| ... return wrapper.count | |
| ... wrapper.count = 0 | |
| ... return wrapper | |
| ... | |
| >>> def while_rec(func, pred): | |
| ... result = func() | |
| ... if pred(result) is False: | |
| ... return result | |
| ... return while_rec(func, pred) | |
| ... | |
| >>> while_rec(counter(), lambda x: x != 10) | |
| 10 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment