Question about generators

Piet van Oostrum piet at cs.uu.nl
Mon Jul 13 04:01:53 EDT 2009


>>>>> Cameron Pulsford <cameron.pulsford at gmail.com> (CP) wrote:

>CP> I read it on the haskell site in their sieves/prime wheel section,
>CP> I guess I misunderstood something. (east to do over there...) I did
>CP> verify it against established list of primes and other generators
>CP> I've written that use more normal methods, but I only hand verified
>CP> it.

If it is used in a sieve then the non-primes will be sieved out.

>CP> It is at least interesting though, I can probably extend it to
>CP> check for primality by using a more normal sieve method. It might
>CP> be pretty fast too because generally it does only generate primes,
>CP> and the few non primes it does generate could be caught quickly
>CP> using a scratching out technique.

it does only generate primes => it does generate all primes.

>CP> When I was initially looking at it there are some interesting
>CP> patterns I might be able to extend into a generator that would
>CP> yield only correct sets of numbers for the 6x + n pattern.

As I wrote in my previous reply, in your use case the non-primes are
harmless. But it is useful to reflect that in the naming of your
identifiers. 

*And please, don't top post.*

-- 
Piet van Oostrum <piet at cs.uu.nl>
URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4]
Private email: piet at vanoostrum.org



More information about the Python-list mailing list