Re: DeleteCases and multiple patterns
- To: mathgroup at smc.vnet.net
- Subject: [mg93995] Re: DeleteCases and multiple patterns
- From: dimitris <dimmechan at yahoo.com>
- Date: Mon, 1 Dec 2008 07:01:47 -0500 (EST)
- References: ggr217$e21$1@smc.vnet.net
On 29 =CD=EF=DD, 11:29, guerom00 <guero... at gmail.com> wrote: > Hello everyone :) > > I have, say a list of list. Each element is a list of length 3 i.e. > > myList={{x1,y1,z1},{x2,y2,z2},...{xN,yN,zN}} > > Now, let's say I want to delete from this list the element which have > x=2 and 3 using DeleteCases. > This works : > > DeleteCase[myList,{2,_,_}] > DeleteCases[myList,{3,_,_}] > > but I would like to use > > DeleteCases[myList,{{2,_,_},{3,_,_}}] > > and this does not work... > > How do I combine multiple patterns in DeleteCases ? > > Thanks in advance. Hi, In[19]:= mylist = Table[Random[Integer, {0, 5}], {10}, {3}] Out[19]= {{1, 2, 1}, {3, 5, 3}, {2, 5, 1}, {0, 5, 0}, {3, 2, 0}, {4, 1, 0}, {1, 3, 5}, {0, 0, 2}, {0, 3, 4}, {4, 1, 4}} In[20]:= DeleteCases[mylist, {2, _, _} | {3, _, _} | {0, _, _}] Out[20]= {{1, 2, 1}, {4, 1, 0}, {1, 3, 5}, {4, 1, 4}} In[15]:= Names["|"] Out[15]= {"Alternatives"} Dimitris PS See http://verbeia.com/mathematica/tips/Tricks.html for a supplementery help browser from a mathematica guru regarding such functions. Regards Dimitris