Re: DeleteCases and multiple patterns
- To: mathgroup at smc.vnet.net
- Subject: [mg93966] Re: DeleteCases and multiple patterns
- From: Bill Rowe <readnews at sbcglobal.net>
- Date: Sun, 30 Nov 2008 06:58:09 -0500 (EST)
On 11/29/08 at 4:29 AM, guerom00 at gmail.com (guerom00) wrote: >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 ? Rather than trying to use multiple patterns, try using a single pattern using Alternatives. That is DeleteCases[myList, {Aternatives@@{2,3},__}] or DeleteCases[myList, {2 | 3,__}] will do what you want