Skip to content

Instantly share code, notes, and snippets.

@tomthepythonist
Created January 21, 2010 04:37
Show Gist options
  • Save tomthepythonist/282585 to your computer and use it in GitHub Desktop.
Save tomthepythonist/282585 to your computer and use it in GitHub Desktop.
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