Re: functional routine for {a, b, c, ...} -> {a - b, b - c, c - ...}

• To: mathgroup at smc.vnet.net
• Subject: [mg24900] Re: [mg24892] functional routine for {a, b, c, ...} -> {a - b, b - c, c - ...}
• From: Ken Levasseur <Kenneth_Levasseur at uml.edu>
• Date: Sun, 20 Aug 2000 01:34:51 -0400 (EDT)
• Organization: UMass Lowell
• References: <200008190846.EAA09632@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```Maarten

This will work :

Partition[lst, 2, 1] /. {{a_, b_} -> b - a}

Ken Levasseur
Math. Sciences
UMass Lowell

***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** *****
Starting Sept 6:
Abstract Algebra I: an on-line course usingMathematica!
See http://cybered.uml.edu/descriptions/cy_92.421.htm for details
***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** *****

Maarten.vanderBurgt at icos.be wrote:
>
> Hallo,
>
>  element.
> I found two ways for doing this:
>
> lst = {a, b, c, d, e, f, g, h};
>
> Table[lst[[i]] - lst[[i + 1]], {i, 1, Length[lst] - 1}]
> {a - b, b - c, c - d, d - e, e - f, f - g, g - h}
>
> ListCorrelate[{1, -1}, lst]
> {a - b, b - c, c - d, d - e, e - f, f - g, g - h}
>
> The first method is rather clumsy and the 2nd one is quite short, but not
> really obvious.
> Initally I was looking for a functional programming style routine.
> Something like: (#[[i]]-#[[i-1]])&/@lst.
> Who can tell me how to do this in a functional programming style?
>
> Thanks
>
> Maarten van der Burgt
> Leuven, Belgium

```

• Prev by Date: Re: make matrix animate
• Next by Date: Re: bug in complex integral?
• Previous by thread: functional routine for {a, b, c, ...} -> {a - b, b - c, c - ...}
• Next by thread: Re: functional routine for {a, b, c, ...} -> {a - b, b - c, c - ...}