MathGroup Archive 2003

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

Search the Archive

Re: nth differences

  • To: mathgroup at smc.vnet.net
  • Subject: [mg39854] Re: [mg39852] nth differences
  • From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
  • Date: Sun, 9 Mar 2003 05:26:25 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

Here is one way:



f[l_List,n_Integer?Positive]:=Nest[ListConvolve[{1,-1},#]&,l,n]


l={1,2,5,7,8,9};


f[l,1]


{1,3,2,1,1}


f[l,2]


{2,-1,-1,0}

In[5]:=
f[l,3]


{-3,0,1}

Andrzej Kozlowski
Yokohama, Japan
http://www.mimuw.edu.pl/~akoz/
http://platon.c.u-tokyo.ac.jp/andrzej/


On Saturday, March 8, 2003, at 04:52  pm, Zachary Turner wrote:

> 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: Re: How to convert string to variable name
  • Previous by thread: Re: nth differences
  • Next by thread: Re: nth differences