MathGroup Archive 2006

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

Search the Archive

Re: Need pure function to opeate on integer lists

  • To: mathgroup at smc.vnet.net
  • Subject: [mg68135] Re: Need pure function to opeate on integer lists
  • From: Bill Rowe <readnewsciv at earthlink.net>
  • Date: Tue, 25 Jul 2006 04:01:37 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

On 7/24/06 at 12:55 AM, tharter at attglobal.net (Terry) wrote:

>Suppose I have a list of integers, such as

>listA = {1,2,5,6,7,12,13,15,16,17,18,22,23,24}

>how do I construct a pure function that will difference successive
>integer elements to produce

>{1-24,2-1,5-2,6-5,7-6,12-7,13-12,15-13,16-15,17-16,18-17,22-18,23-22
>,24-23}

ListConvolve will do what you need. That is

In[4]:=
ListConvolve[{1,-1},listA,{1,1}]

Out[4]=
{-23,1,3,1,1,5,1,2,1,1,1,4,1,1}

and to make it a pure function use

ListConvolve[{1,-1},#,{1,1}]&
--
To reply via email subtract one hundred and four


  • Prev by Date: Deleting charachter from a text file
  • Next by Date: Re: Need pure function to opeate on integer lists
  • Previous by thread: Re: Need pure function to opeate on integer lists
  • Next by thread: Re: Need pure function to opeate on integer lists