test
view primes.py @ 0:3e1445510fe7
a
author | test |
---|---|
date | Thu Jan 01 00:00:00 1970 +0000 (many years ago) |
parents | |
children |
line source
1 #!/usr/bin/env python
3 """Fun with generators. Corresponding Haskell implementation:
5 primes = 2 : sieve [3, 5..]
6 where sieve (p:ns) = p : sieve [n | n <- ns, mod n p /= 0]
7 """
12 """Generate all primes."""
15 # It is important to yield *here* in order to stop the
16 # infinite recursion.