Re: DeleteCases
- To: mathgroup at smc.vnet.net
- Subject: [mg42240] Re: DeleteCases
- From: bobhanlon at aol.com (Bob Hanlon)
- Date: Wed, 25 Jun 2003 01:53:34 -0400 (EDT)
- References: <bd8o3o$loi$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
list1={21,41,61,71,81}; list2={71,73,75,77,79,81}; list3=DeleteCases[list1, _?(MemberQ[list2, #]&)] {21,41,61} list3=Cases[list1, _?(!MemberQ[list2,#]&)] {21,41,61} list3=Select[list1, !MemberQ[list2,#]&] {21,41,61} Bob Hanlon In article <bd8o3o$loi$1 at smc.vnet.net>, "Shawn Kelly" <kellysm at ornl.gov> wrote: << Subject: DeleteCases From: "Shawn Kelly" <kellysm at ornl.gov> To: mathgroup at smc.vnet.net Date: Tue, 24 Jun 2003 05:38:00 +0000 (UTC) I have twos lists I want to compare with one another and delete the cases where the elements in list1 match list2. For example: list1={21,41,61,71,81} list2={71,73,75,77,79,81} I want the new list3 to read: list3={21,41,61} It seems to me that the following should work: list3=DeleteCases[list1,list2] >><BR><BR>