Created
July 12, 2012 04:44
-
-
Save myuon/3095838 to your computer and use it in GitHub Desktop.
Infinite list sample like Haskell on python!
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
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