Created
January 21, 2010 04:37
-
-
Save tomthepythonist/282585 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
if __name__ == '__main__': | |
#fibonnacci sequence in a lazy list. | |
@lazylist | |
def fibgen(lst): | |
yield 0 | |
yield 1 | |
for a, b in itertools.izip(lst, lst[1:]): | |
yield a + b | |
fibs = fibgen() #now fibs can be indexed or iterated over as if it were | |
#an infinitely long list containing the fibonnaci sequence |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment