Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #81477

Re: Comprehension with two variables - explanation needed

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <drsalists@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.049
X-Spam-Evidence '*H*': 0.90; '*S*': 0.00; 'subject:two': 0.07; 'cc:addr:python-list': 0.11; '23,': 0.16; 'cc:name:python list': 0.16; 'haskell,': 0.16; 'to:addr:pearwood.info': 0.16; "to:name:steven d'aprano": 0.16; 'wrongly': 0.16; 'wrote:': 0.18; 'cc:addr:python.org': 0.22; '(or': 0.24; 'cc:2**0': 0.24; 'least': 0.26; 'header:In-Reply-To:1': 0.27; 'message-id:@mail.gmail.com': 0.30; "d'aprano": 0.31; 'steven': 0.31; 'subject:with': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'version': 0.36; 'described': 0.36; 'that!': 0.36; 'url:org': 0.36; 'sometimes': 0.38; 'nov': 0.38; 'subject:needed': 0.38; 'pm,': 0.38; 'read': 0.60; 'subject:skip:C 10': 0.61; 'first': 0.61; 'due': 0.66; 'horrible': 0.84; 'inefficient': 0.91
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=oZAFWVXeJCSpZqecdo1icOCDJRgJNrcOuqYfAiNojGU=; b=b0gl/EYKQajTFN+iUVMgDVIR/IJ5ap39aGCRbFubXIFlH2mEcEmm605ZjVqYmosQO3 3u6R3qs3g4/WVwHsfcYm9IZQ/1Y0HwUZf+E/ERfVLsjYlklXcN4KetNeoupwY/0PpTjv ZKU7lojTsy7gQESPd0TGVEHVIQRUqGkSZalQb6Vj6eVmhfXiH+Lr2cdUcW/wkWIALTiq 5k3EgHFQS49+FmDH9KOD/KiLdmoSb2+8WUs+W38Ah+iRj3qGGLEYFBYfKvcn1Drlu4iK b+2z7bb5xR7yorVXnsH9YwCaEnzwTWEOVl8zljhL5mYZ73KntQ4vKjp8872rQQHIUJUt 43hQ==
MIME-Version 1.0
X-Received by 10.112.201.72 with SMTP id jy8mr23193847lbc.65.1416876126143; Mon, 24 Nov 2014 16:42:06 -0800 (PST)
In-Reply-To <5472b74d$0$12979$c3e8da3$5496439d@news.astraweb.com>
References <mailman.16184.1416754678.18130.python-list@python.org> <d1194d28-e9ed-4bd3-86e9-899e13a17097@googlegroups.com> <002501d00733$6995dce0$3cc196a0$@gmail.com> <mailman.16191.1416757555.18130.python-list@python.org> <roy-B11F64.10563923112014@news.panix.com> <07f25264-1286-4d98-820c-949dba711248@googlegroups.com> <5472b74d$0$12979$c3e8da3$5496439d@news.astraweb.com>
Date Mon, 24 Nov 2014 16:42:06 -0800
Subject Re: Comprehension with two variables - explanation needed
From Dan Stromberg <drsalists@gmail.com>
To "Steven D'Aprano" <steve@pearwood.info>
Content-Type text/plain; charset=UTF-8
Cc Python List <python-list@python.org>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.16260.1416876136.18130.python-list@python.org> (permalink)
Lines 16
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1416876136 news.xs4all.nl 2867 [2001:888:2000:d::a6]:36861
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:81477

Show key headers only | View raw


On Sun, Nov 23, 2014 at 8:42 PM, Steven D'Aprano <steve@pearwood.info> wrote:
> On Sun, 23 Nov 2014 08:45:39 -0800, Rustom Mody wrote:
>> First a one-line solution in haskell
>>
>> sieve (p:xs)   =    p:sieve [x | x <- xs, x `mod` p /= 0]
>
> Don't use that! That is a horribly inefficient way to generate primes.
>
> Mathematically, it is a version of Euler's Sieve. It is sometimes wrongly
> described as "Sieve of Eratosthenes", but that is wrong. Due to it's
> horrible performance, Melissa O'Neill calls this the "Sleight on
> Eratosthenes":

I don't read Haskell, but here's a Sieve (or at least I thought it was
a Sieve) and a few other prime-related things:
http://stromberg.dnsalias.org/~dstromberg/primes/

Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Comprehension with two variables - explanation needed "Ivan Evstegneev" <webmailgroups@gmail.com> - 2014-11-23 16:56 +0200
  Re: Comprehension with two variables - explanation needed Rustom Mody <rustompmody@gmail.com> - 2014-11-23 07:09 -0800
    RE: Comprehension with two variables - explanation needed "Ivan Evstegneev" <webmailgroups@gmail.com> - 2014-11-23 17:37 +0200
    Re: Comprehension with two variables - explanation needed Chris Angelico <rosuav@gmail.com> - 2014-11-24 02:42 +1100
    RE: Comprehension with two variables - explanation needed Skip Montanaro <skip.montanaro@gmail.com> - 2014-11-23 09:45 -0600
      Re: Comprehension with two variables - explanation needed Roy Smith <roy@panix.com> - 2014-11-23 10:57 -0500
        Re: Comprehension with two variables - explanation needed Rustom Mody <rustompmody@gmail.com> - 2014-11-23 08:45 -0800
          Re: Comprehension with two variables - explanation needed Rustom Mody <rustompmody@gmail.com> - 2014-11-23 09:17 -0800
          RE: Comprehension with two variables - explanation needed "Ivan Evstegneev" <webmailgroups@gmail.com> - 2014-11-23 19:27 +0200
          Re: Comprehension with two variables - explanation needed Steven D'Aprano <steve@pearwood.info> - 2014-11-24 04:42 +0000
            Re: Comprehension with two variables - explanation needed Chris Angelico <rosuav@gmail.com> - 2014-11-24 15:51 +1100
              Re: Comprehension with two variables - explanation needed Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-11-25 09:20 +1100
            Re: Comprehension with two variables - explanation needed Rustom Mody <rustompmody@gmail.com> - 2014-11-23 22:47 -0800
            Re: Comprehension with two variables - explanation needed Dan Stromberg <drsalists@gmail.com> - 2014-11-24 16:42 -0800
        Re: Comprehension with two variables - explanation needed Skip Montanaro <skip.montanaro@gmail.com> - 2014-11-23 10:45 -0600
        Re: Comprehension with two variables - explanation needed Roy Smith <roy@panix.com> - 2014-11-23 12:08 -0500
        Re: Comprehension with two variables - explanation needed Jon Ribbens <jon+usenet@unequivocal.co.uk> - 2014-11-23 17:46 +0000

csiph-web