Re: DeleteCases and multiple patterns
- To: mathgroup at smc.vnet.net
- Subject: [mg93985] Re: DeleteCases and multiple patterns
- From: Raffy <raffy at mac.com>
- Date: Mon, 1 Dec 2008 06:59:58 -0500 (EST)
- References: <ggr217$e21$1@smc.vnet.net>
On Nov 29, 4:29 am, 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.
DeleteCases[ myList, {2,_,_}|{3,_,_} ]
DeleteCases[ myList, {2|3, _, _} ]
However, if your search only involves the first element, the following
would be faster:
Pick[ myList, myList[[All, 1]], Except[2 | 3, _Integer]]