MathGroup Archive 2009

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

Search the Archive

Re: how to get the longest ordered sub sequence of a list in

  • To: mathgroup at smc.vnet.net
  • Subject: [mg103215] Re: how to get the longest ordered sub sequence of a list in
  • From: dh <dh at metrohm.com>
  • Date: Thu, 10 Sep 2009 07:24:48 -0400 (EDT)
  • References: <h87pgp$5gt$1@smc.vnet.net>


Hi,

we can do this with intermediate variables.

E.g. assume the data is in d:

d = RandomInteger[10, 12]

then we get an non-strict increasing sub list by:

t = d[[1]];

Select[d, If[# >= t, t = #; True, False] &]

the following gives a strict increasing  sub list, without the first 

element, that we need to append later:

t = d[[1]];

Select[d, If[# > t, t = #; True, False] &]

Daniel



a boy wrote:

> how to get a (strict or not-strict)decreasing sub sequence of a list?

>                                              ----------------

>  

> increasing                                   ?

> 




  • Prev by Date: Re: how to get the longest ordered sub sequence of a list in
  • Next by Date: Re: Print in a loop
  • Previous by thread: Re: how to get the longest ordered sub sequence of a list in
  • Next by thread: Re: Re: how to get the longest ordered sub sequence of a