MathGroup Archive 2003

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

Search the Archive

Re: Super-Increasing List

  • To: mathgroup at smc.vnet.net
  • Subject: [mg40499] Re: Super-Increasing List
  • From: atelesforos at hotmail.com (Orestis Vantzos)
  • Date: Tue, 8 Apr 2003 03:04:08 -0400 (EDT)
  • References: <b6m04c$efg$1@smc.vnet.net> <b6reg3$7rk$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Dr Bob alerted me that the function does not work right.
The error was in the way the function begun (sum=0).
This is the corrected version:

correctedSuperIncreasingQ[lst_] := OrderedQ[lst] &&
Module[{sum = First[lst]}, If[Scan[If[# <= sum, Return[False], sum +=
#] &, Rest[lst]] ===
Null, True,
False]];

Orestis

atelesforos at hotmail.com (Orestis Vantzos) wrote in message news:<b6reg3$7rk$1 at smc.vnet.net>...
> OrestisSuperIncreasingQ[lst_] := OrderedQ[lst] &&
>       Module[{sum = 0}, 
>         If[Scan[If[# <= sum, Return[False], sum += #] &, lst] ===
> Null, True,
>           False]];
> 
> The advantage of this function is that it stops checking as long as an
> element does not satisfy the super-increasing condition.
> Orestis
> 
> "flip" <flip_alpha at safebunch.com> wrote in message news:<b6m04c$efg$1 at smc.vnet.net>...
> > Hello,
> > 
> > does a command or module exist which can test a list of values and determine
> > if it is a super-increasing list?
> > 
> > A super-increasing list satifies the conditions:
> > 
> > a.  the list is in increasing order
> > b.  each element of the list is greater than the sum of it's previous
> > elements
> > 
> > Example:
> > 
> > list = {2, 3, 7, 15, 31}
> > 
> > So check:
> > 
> > a.  It is in  increasing order and
> > b.   3 > 2, 7 > 3+ 2, 15 > 7 + 3 + 2 and 31 > 15 + 7 + 3 + 2,
> > 
> > hence the list is super-increasing.
> > 
> > Thanks for any inputs, Flip
> > 
> > To email me, remove "_alpha".


  • Prev by Date: RE: Variable number of intervals
  • Next by Date: RE: Re: Super-Increasing List
  • Previous by thread: Re: Re: Super-Increasing List
  • Next by thread: RE: Re: Super-Increasing List