filter2

Quinn Dunkan quinn at groat.ugcs.caltech.edu
Sat Jun 15 01:49:33 EDT 2002


On Thu, 13 Jun 2002 18:50:23 +0400, Oleg Broytmann <phd at phd.pp.ru> wrote:
>On Thu, Jun 13, 2002 at 04:39:51PM +0200, Thomas Heller wrote:
>> 
>> "Oleg Broytmann" <phd at phd.pp.ru> wrote in message
news:mailman.1023975618.6474.python-list at python.org...
>> >    I want to have new python builtin - filter2. It is exactly like filter,
>> > but it returns also a list of items that didn't pass the test.
>> 
>> IIRC, in Smalltalk they were named 'select' (like filter), and 'reject' (like your filter2).
>> IMO these are much better names then filter and filter2.
>
>   It is too late to rename builtin filter, so I modelled fiter2 after it.

In haskell they call it "partition" which I think is better since the
emphasis is that it returns both selected and rejeted.

I wrote mine in python with a plain for loop.  I'm not sure C would really get
you that much efficiency, but it would be easy enough to find out.

Not sure it's worth being in the core (maybe there should be a module for
list utils or something), but I like partition better than filter2.



More information about the Python-list mailing list