Created
March 13, 2014 00:00
-
-
Save JackDanger/9519283 to your computer and use it in GitHub Desktop.
Recursion!
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 a_little_recursion(n): | |
| if n > 100: | |
| print "all done!" | |
| print "not done yet!" | |
| return | |
| a_little_recursion(n + 1) | |
| a_little_recursion(0) |
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 recurse_just_once(should_i_stop): | |
| if should_i_stop: | |
| print "stop now!" | |
| return | |
| recurse_just_once(True) | |
| recurse_just_once(False) |
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 too_much_recursion(n): | |
| print n | |
| return recurse(n + 1) | |
| too_much_recursion(0) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment