MathGroup Archive 2003

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

Search the Archive

Re: nth differences

  • To: mathgroup at smc.vnet.net
  • Subject: [mg39879] Re: nth differences
  • From: "Steve Luttrell" <luttrell at _removemefirst_westmal.demon.co.uk>
  • Date: Sun, 9 Mar 2003 05:30:37 -0500 (EST)
  • References: <b4c9lo$nqg$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Try the following:

FixedPointList[(#1[[2]] - #1[[1]] & ) /@
    Partition[#1, 2, 1] & , {1, 2, 5, 7, 8, 9}]

which produces the list

{{1, 2, 5, 7, 8, 9}, {1, 3, 2, 1, 1}, {2, -1, -1, 0}, {-3, 0, 1}, {3, 1},
{-2}, {}, {}}

Just strip off the last two elements and it does what you want.

--
Steve Luttrell
West Malvern, UK

"Zachary Turner" <_NOzturnerSPAM_ at cyberonic.com> wrote in message
news:b4c9lo$nqg$1 at smc.vnet.net...
> Say I have a list of k integers and I want to produce a list containing
the
> first differences?  For example, given {1, 2, 5, 7, 8, 9} the first
> differences are {1, 3, 2, 1, 1}, and the second differences are
{2, -1, -1,
> 0}, the third are {-3, 0, 1}, etc
>
>
>




  • Prev by Date: Re: nth differences
  • Next by Date: Help with Format Background Color Cell Gray Box
  • Previous by thread: Re: nth differences
  • Next by thread: Re: nth differences