Created
September 7, 2010 21:38
-
-
Save gregglind/569165 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
import sys | |
def pr(x): | |
sys.stdout.write(str(x)+"\n") | |
def gen_primes_1a(): | |
seq = count(2) | |
seq = ((x,0) for x in seq) | |
while True: | |
p,old = seq.next() | |
seq = ((x,pr("%i over %i" %(x,p))) for (x,blah) in seq if x%p) | |
yield p | |
print(list(islice(gen_primes_1a(), 10))) | |
# this shows the problem |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment