Re: Need pure function to opeate on integer lists
- To: mathgroup at smc.vnet.net
- Subject: [mg68124] Re: [mg68103] Need pure function to opeate on integer lists
- From: Bob Hanlon <hanlonr at cox.net>
- Date: Tue, 25 Jul 2006 04:01:23 -0400 (EDT)
- Reply-to: hanlonr at cox.net
- Sender: owner-wri-mathgroup at wolfram.com
listA = {1,2,5,6,7,12,13,
15,16,17,18,22,23,24};
(#-RotateRight[#])&[listA]
{-23,1,3,1,1,5,1,2,1,1,1,4,1,1}
ListConvolve[{1,-1}, #,1]&[listA]
{-23,1,3,1,1,5,1,2,1,1,1,4,1,1}
ListCorrelate[{-1,1}, #,-1]&[listA]
{-23,1,3,1,1,5,1,2,1,1,1,4,1,1}
%==%%==%%%
True
Bob Hanlon
---- Terry <tharter at attglobal.net> wrote:
> Hi All,
> 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}
>
> Thanks in advance
> .....Terry
>