Re: DeleteCases
- To: mathgroup at smc.vnet.net
- Subject: [mg42244] Re: [mg42224] DeleteCases
- From: Tomas Garza <tgarza01 at prodigy.net.mx>
- Date: Wed, 25 Jun 2003 01:53:39 -0400 (EDT)
- References: <200306240527.BAA22169@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Perhaps this will do the job:
In[1]:=
Select[list1,Not[MemberQ[list2,#]]&]
Out[1]=
{21,41,61}
or
In[2]:=
DeleteCases[list1,y_/;MemberQ[list2,y]]
Out[2]=
{21,41,61}
Tomas Garza
Mexico City
----- Original Message -----
From: "Shawn Kelly" <kellysm at ornl.gov>
To: mathgroup at smc.vnet.net
Subject: [mg42244] [mg42224] DeleteCases
> 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]
>
> Any thoughts?
>
> Thanks
>
> Shawn
>
>
>
- References:
- DeleteCases
- From: "Shawn Kelly" <kellysm@ornl.gov>
- DeleteCases