Skip to content

Instantly share code, notes, and snippets.

@myuon
Created July 12, 2012 04:44
Show Gist options
  • Save myuon/3095838 to your computer and use it in GitHub Desktop.
Save myuon/3095838 to your computer and use it in GitHub Desktop.
Infinite list sample like Haskell on python!
def inflist(a,n):
while True:
a.append((a[1]-a[0])*n)
yield n
n+=1
def take(n,a):
b=[]
for i in range(n):
b.append(a.next())
return b
print take(500,inflist([0,1],1))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment