Re: Delete cases nested list
- To: mathgroup at smc.vnet.net
- Subject: [mg42784] Re: Delete cases nested list
- From: bobhanlon at aol.com (Bob Hanlon)
- Date: Fri, 25 Jul 2003 11:54:53 -0400 (EDT)
- References: <bfqt01$nsu$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
lis3=DeleteCases[lis1,
_?(Intersection[#, lis2]!={}&)]
or
lis3=DeleteCases[lis1,
_?(MemberQ[lis2, Last[#]]&)]
Bob Hanlon
In article <bfqt01$nsu$1 at smc.vnet.net>, "The Leddons" <jleddon1 at comcast.net>
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};
lis3 = DeleteCases[lis1, {x_lis2}, {2}]
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.