Mathematica 9 is now available
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: [mg52906] Re: [mg52871] Delete problem
  • From: DrBob <drbob at bigfoot.com>
  • Date: Thu, 16 Dec 2004 03:41:01 -0500 (EST)
  • References: <200412150926.EAA10676@smc.vnet.net>
  • Reply-to: drbob at bigfoot.com
  • Sender: owner-wri-mathgroup at wolfram.com

"ccheck" is given a value before the While loop starts and never updated to the new "index". Since the test is true for index==1, all the sublists are deleted. You can change to this:

original = {{{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}}};

masterlist = original;
index = 1;
While[index â?¤ Length[masterlist],
     ccheck = Sign[masterlist[[index, All, 9]]];
     If[Count[ccheck, _?Positive] > 0 &&
         Count[ccheck, _?Negative] > 0 && Count[ccheck, _Integer] == 3,
            masterlist = Delete[masterlist, index], index++]];
masterlist

or, a bit nicer:

selector[data : {__List}] := Select[data, (Length@# â?  3 ||
    Count[#, {__, _?Negative}] == 0 || Count[#, {__, _?Positive}] == 0) &]
masterlist = selector@original

Bobby

On Wed, 15 Dec 2004 04:26:54 -0500 (EST), Todd Allen <genesplicer28 at yahoo.com> wrote:

> Hi everyone,
>    I have situation where I am trying to quality
> control check a "list of lists" for certain values
> that should be deleted from the list if they are
> found.  I have wrote a few lines of code that I
> believe should work, but rather than simply deleting a
> part of the list,  mathematica seems to delete the
> entire list.  Below is the situation with a small test
> dataset:
>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++]];
>I am trying to delete lists that have both positive
> and negative values in the ninth position of common
> elements and also have only 3 members of that group.
> For example, I would expect mathematica to delete the
> first group of masterlist above, because it has three
> subgroups of AEST-01-C-10 and it has the values of
> -2.14, -1.1and 1.79 in each of the three AEST-01-C-10
> elements.  Sorry if I have badgered the proper use of
> list/grouping terminology, but hopefully my general
> idea is clear.
>Thank you for any thoughts you might have.
>Best regards,
> Todd
>
>
>
>
> 		
> __________________________________
> Do you Yahoo!?
> Yahoo! Mail - Helps protect you from nasty viruses.
> http://promotions.yahoo.com/new_mail
>
>
>
>



-- 
DrBob at bigfoot.com
www.eclecticdreams.net


  • References:
  • Prev by Date: Re: Re: Intersection of two surfaces in 3D
  • Next by Date: Re: Integrate in version 5.1
  • Previous by thread: Re: Delete problem
  • Next by thread: Re: Delete problem