Re: DeleteCases : several at once, conditions
- To: mathgroup at smc.vnet.net
- Subject: [mg49373] Re: DeleteCases : several at once, conditions
- From: BobHanlon at aol.com
- Date: Sat, 17 Jul 2004 06:38:37 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
data={{1,6,7},{3,6,9},{1,2,11},{3,5,9},{2,5,6},{2,9,11},{2,10,11},{3,7,9},{5,
8,11},{3,7,9},{7,8,9},{2,5,12},{2,6,10},{2,10,11},{1,6,9},{6,10,
12},{3,6,12},{2,5,12},{3,8,9},{1,2,7}};
DeleteCases[data, {1|3|5|7,_,_}]
{{2, 5, 6}, {2, 9, 11}, {2, 10, 11}, {2, 5, 12},
{2, 6, 10}, {2, 10, 11}, {6, 10, 12}, {2, 5, 12}}
%==DeleteCases[data, {_?OddQ,_,_}]==
DeleteCases[data,{ _?(Mod[#,2]==1&),_,_}]
True
Bob Hanlon
> In a message dated Fri, 16 Jul 2004 10:35:35 +0000 (UTC),
> camerzone at yahoo.com writes: Suppose you have a list of lists, something like
> {{1, 6, 7}, {3, 6, 9}, {1, 2, 11}, {3, 5, 9}, {2, 5, 6}, {2, 9, 11}, {
> 2, 10, 11}, {3, 7, 9}, {5, 8, 11}, {3, 7, 9}, {7, 8, 9}, {2, 5, 12},
> {2, 6,
> 10}, {2, 10, 11}, {1, 6, 9}, {6, 10, 12}, {3, 6, 12}, {2, 5, 12},
> {3, 8,
> 9}, {1, 2, 7}}
> and you want to delete cases matching several different patterns, say
> {1,_,_} and {9,_,_}
> What's the most efficient way?
>
> Also, can you use conditions with DeleteCases? Say, I want to delete
> all cases containing even numbers?
>