[Edu-sig] Generating prime numbers
kirby urner
kirby.urner at gmail.com
Sun Apr 5 18:07:47 CEST 2009
As my grandmother might have said: ai yai yai
http://answers.yahoo.com/question/index?qid=20081203103806AA4TSOq
I'm guessing Kay (XY? XX? -- not that I need to know) is a LISP and/or
Scheme head, by the looks of those lambdas. Probably why Python
doesn't want a big one is precisely this: the language would fall
under the control of the Great Lambda Kings (a small tribe to our
north, spends all its time extending emacs).
Ya gotta love 'em!
Kirby
On Sun, Apr 5, 2009 at 8:27 AM, John Posner <jjposner at snet.net> wrote:
> kirby urner wrote:
>>
>> Excellente! kind sir.
>>
>
> Here's a Python solution from Kay Schluehr on python-list. I've
> pretty-printed it, sort of. If the line endings get garbled, just look for
> the backslashes:
>
> g = (lambda primes = []: \
> (n for n in count(2) if \
> (lambda n, primes: \
> (n in primes if (primes and n<=primes[-1]) \
> else (primes.append(n) or True if all(n%p for p
> in primes if p <= sqrt(n)) \
> else False) \
> ) \
> )(n, primes) \
> ) \
> )()
>
> "g" is a generator, so get the values with g.next().
>
>
>> On Sat, Apr 4, 2009 at 2:30 PM, Edward Cherlin <echerlin at gmail.com> wrote:
>>
>>>
>>> Your message text got stuck in an attachment, where I almost missed
>>> it. I wonder what your mail system thinks it is doing? Comment below.
>>>
>
> Yes, I know it's bad. This message is sent from Thunderbird 2.0.0.21,
> instead of MS-Outlook 2003. Any better?
>
> -John
>
>
More information about the Edu-sig
mailing list