Re: reduce expression to test sublist

2013-01-05 Thread Dave Angel
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) -

Re: reduce expression to test sublist

2013-01-05 Thread Terry Reedy
On 1/5/2013 1:25 PM, Asim wrote: Hi All The following reduce expression checks if every element of list lst1 is present in list lst2. It works as expected for integer lists but for lists of strings, it always returns False. reduce( lambda x,y: (x in lst2) and (y in lst2), lst1) reduce(lambda

Re: reduce expression to test sublist

2013-01-05 Thread Terry Reedy
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 ite

Re: reduce expression to test sublist

2013-01-05 Thread Jussi Piitulainen
Asim writes: > Hi All > > The following reduce expression checks if every element of list lst1 > is present in list lst2. It works as expected for integer lists but > for lists of strings, it always returns False. > >reduce( lambda x,y: (x in lst2) and (y in lst2), lst1) Possibly this:

Re: reduce expression to test sublist

2013-01-05 Thread chaouche yacine
- Original Message - From: Asim To: python-list@python.org Cc: Sent: Saturday, January 5, 2013 7:25 PM Subject: reduce expression to test sublist Hi All The following reduce expression checks if every element of list lst1 is present in list lst2.  It works as expected for integer

Re: reduce expression to test sublist

2013-01-05 Thread Dave Angel
On 01/05/2013 01:25 PM, Asim wrote: > Hi All > > The following reduce expression checks if every element of list lst1 is > present in list lst2. It works as expected for integer lists but for lists > of strings, it always returns False. > >reduce( lambda x,y: (x in lst2) and (y in lst2), lst

reduce expression to test sublist

2013-01-05 Thread Asim
Hi All The following reduce expression checks if every element of list lst1 is present in list lst2. It works as expected for integer lists but for lists of strings, it always returns False. reduce( lambda x,y: (x in lst2) and (y in lst2), lst1) Moreover, for the lists of strings the follo