MathGroup Archive 2003

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Delete cases nested list

  • To: mathgroup at smc.vnet.net
  • Subject: [mg42794] Re: Delete cases nested list
  • From: Bill Rowe <listuser at earthlink.net>
  • Date: Sat, 26 Jul 2003 04:33:02 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

On 7/25/03 at 5:08 AM, jleddon1 at comcast.net (The Leddons) wrote:

> I have 2 lists, lis1 and lis2, I want to compare to each other for the 
> purpose of deleting sublists of lis1 that have elements matching those 
> in lis2. I tried this:

> lis1 = {{2, 3, 4, 5, 6, 7, C1}, {2, 3, 4, 5, 6, 71, B6}, {1, 2, 3, 4, 
> 5, 6, C11}, {4, 5, 6, 7, 8, 7, C4}, {23, 3, 2, 5, 6, 7, M2}, {2, 3, 9, 
> 5, 6, 71, B3}};

> lis2 = {C11, B6, B3};

> What I want is:

> lis3 = {{2, 3, 4, 5, 6, 7, C1}, {4, 5, 6, 7, 8, 7, C4}, {23, 3, 2, 5, 6, 7, 
> M2}};

> However, this didn't work. Note that I want to delete all cases containing B.

I am not entirely sure what you are trying to do. Your words say "delete all cases containing B" but what you show as desired also deletes the third item of lis1 which does not contain a symbol that starts with B. I will assume what you show as lis3 is what you want. In that case either

lis3 =Select[lis1, ! MemberQ[lis2, Last@#] &]

or

Complement[lis1, Select[lis1, Length@Intersection[#, lis2] > 0 &]]

should work. The first of these assumes the element that identifies sublists to be deleted is always the last element of those sublists. The second makes no assumptions about the position of the element that identifies the sublists to be deleted.


  • Prev by Date: Re: v5 FrontEnd problem on Linux
  • Next by Date: Two successive plots, in a single cell, how to get same transverse axis scaling?
  • Previous by thread: RE: Delete cases nested list
  • Next by thread: Re: Delete cases nested list