Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2004
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2004

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Delete problem

  • To: mathgroup at smc.vnet.net
  • Subject: [mg52904] Re: [mg52871] Delete problem
  • From: William K Reinholtz <kirk.reinholtz at jpl.nasa.gov>
  • Date: Thu, 16 Dec 2004 03:40:51 -0500 (EST)
  • References: <200412150926.EAA10676@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Todd:

Your problem is begging for the application of the Mathematica pattern  
matching capabilities.  For example:

Cases[masterlist,{{a_,_,_,_,_,_,_,_,p1_},{a_,_,_,_,_,_,_,_,
         p2_},{a_,_,_,_,_,_,_,_,p3_}} /;
     Abs[Plus@@Sign[{p1,p2,p3}]] == 3]

The above will select exactly the "groups" with three elements, all  
with the same first member, and all with the same sign in the 9th  
member.  Take a look at Position[] and Extract[] and you'll see some  
great ways to quickly do what you wish.

By the way it might be a bit obscure as to why the first members must  
match in the above.  It turns out that if a pattern with the same name  
is mentioned several places in a larger pattern (e.g. "a_" above) then  
Mathematica will only match where each pattern has the same exact matched value.  
  It's difficult to get this from the help pages.

Important: You must quote the first item in each list, e.g.  
"AEST-01-C-10" or Mathematica will evaluatate it as an expression.   
There are other ways to prevent such evaluation as well (e.g. via the  
use of Hold[]) but they're trickier to use.


On Dec 15, 2004, at 1:26 AM, Todd Allen wrote:

> masterlist={{{AEST-01-C-10,1,1,1,2,31,1,C,-2.14},{AEST-01-C 
> -10,1,1,1,4,31,1,
>
> C,-1.1},{AEST-01-C-10,2,2,1,2,12,2,C,1.79}},{{AEST-07-E 
> -04,2,1,2,1,10,2,
>
> C,1.334},{AEST-07-E-04,2,1,3,2,1,4,C,1.997},{AEST-07-E-04,3,2,1,1,2,1,
>       C,-1.17},{AEST-07-E-04,3,4,1,1,21,2,C,2.15}}};
>
> index=1;ccheck=Sign[masterlist[[index,All,9]]];While[
>   index<=Length[masterlist],
>   If[Count[ccheck,_?Positive]>0 &&
> Count[ccheck,_?Negative]>0 &&
>
> Count[ccheck,_Integer]==3,masterlist=Delete[masterlist,index],index++]] 
> ;


  • References:
  • Prev by Date: Re: shuffling (randomizing) a series
  • Next by Date: Re: SymbolShape
  • Previous by thread: Delete problem
  • Next by thread: Re: Delete problem