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


Groups > comp.lang.python > #36215

Re: reduce expression to test sublist

Date 2013-01-05 17:05 -0500
From Dave Angel <d@davea.name>
Subject Re: reduce expression to test sublist
References <76cd3945-392e-40d4-9f87-d3956b9521d2@googlegroups.com> <50E877C2.8090208@davea.name> <kca7i0$e9g$1@ger.gmane.org>
Newsgroups comp.lang.python
Message-ID <mailman.149.1357423542.2939.python-list@python.org> (permalink)

Show all headers | View raw


On 01/05/2013 04:55 PM, Terry Reedy wrote:
> On 1/5/2013 1:58 PM, Dave Angel wrote:
>
>> If you're trying to make a faster loop, then I suggest you look into set
>> differences.  Turn both lists into sets, and subtract them.   Something
>> like (untested):
>>
>>     result =  not bool( set(lst1) - set(lst2) )
>
> This does not return False as soon as an item in set1 is found that is
> not in set2.
>
> set(lst1) < set(lst2)
>
> will, and directly return False/True. The OP is trying to compute the
> lst1 < lst2, where lst1 and lst2 are interpreted as sets, rather than
> as sequences with the lexicographic ordering default.
>

Thanks.  I wasn't aware that sets supported ordered comparison that way,
though it makes perfect sense now that you point it out.


-- 

DaveA

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


Thread

reduce expression to test sublist Asim <asim.r.p@gmail.com> - 2013-01-05 10:25 -0800
  Re: reduce expression to test sublist Dave Angel <d@davea.name> - 2013-01-05 13:58 -0500
  Re: reduce expression to test sublist chaouche yacine <yacinechaouche@yahoo.com> - 2013-01-05 11:59 -0800
  Re: reduce expression to test sublist Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2013-01-05 22:41 +0200
  Re: reduce expression to test sublist Terry Reedy <tjreedy@udel.edu> - 2013-01-05 16:55 -0500
  Re: reduce expression to test sublist Terry Reedy <tjreedy@udel.edu> - 2013-01-05 16:55 -0500
  Re: reduce expression to test sublist Dave Angel <d@davea.name> - 2013-01-05 17:05 -0500

csiph-web