Re: Delete elements from list..
- To: mathgroup at smc.vnet.net
 - Subject: [mg116627] Re: Delete elements from list..
 - From: Bill Rowe <readnews at sbcglobal.net>
 - Date: Tue, 22 Feb 2011 04:42:31 -0500 (EST)
 
On 2/21/11 at 7:30 PM, Maarten.VanDerBurgt at kla-tencor.com (Maarten
van der Burgt) wrote:
>I have a list like:
>mylist = {1, 2, 3, 4, 5, 6, 4, 5, 7, 8, 9}
>I want to delete any element which is not strictly larger than the
>previous element, until my new list has only increasing values.
>This means in mylist above I want to delete the 4 and the 5 at
>position 7 and 8.
>Any elegant and fast way for doing this?
Here is one way that should be reasonably fast for a large list
In[29]:= Rest@
  Flatten@Fold[If[Last[#1] < #2, {#1, #2}, #1] &, {0}, mylist]
Out[29]= {1,2,3,4,5,6,7,8,9}
as for elegance, I'll leave that for you to decide.