Created
June 28, 2016 05:29
Star
You must be signed in to star a gist
https://repl.it/C6f4/1 created by charles2588
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
#Generator function yields iterator rather than returning value, no function calls or calls on stack thus saving memory | |
def f(n): | |
for x in range(n): | |
yield x**3 | |
for i in f(5): | |
print(i) | |
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
Python 3.5.1 (default, Dec 2015, 13:05:11) | |
[GCC 4.8.2] on linux | |
0 | |
1 | |
8 | |
27 | |
64 | |
=> None |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment