Re: Function

• To: mathgroup at smc.vnet.net
• Subject: [mg3879] Re: [mg3819] Function
• Date: Sat, 4 May 1996 02:16:33 -0400
• Sender: owner-wri-mathgroup at wolfram.com

```
Greetings Roberto,

Here's a fast way ... using built-in Mma functions:

Map[#[[2]]/#[[1]]&,Partition[list,2,1]]

The Partition function takes your list {a1,a2,a3,....} and builds
the list { {a1,a2}, {a2,a3}, {a3,a4}, {a4,a5}, .....}.  The Map
function operates on this new list, dividing the second element of
each by the first, giving the result I believe you want:

{ a2/a1, a3/a2, a4/a3, ....}

I find the practice of partitioning lists and using "pure" functions
on these partitions very very useful in various data analysis contexts.

Physics UW

On Sat, 27 Apr 1996, Roberto Diego wrote:

>
>  I4m trying to find a function that works on a list like {a1, a2, a3,
> a4, ..., an} and returns a list like {a2/a1, a3/a2, a4/a3, ... an/an-1}.
>
> It should be easy but I can4t find the answer.
>
> Thanks a lot.
>

==== [MESSAGE SEPARATOR] ====

```

• Prev by Date: Re: Help on Function
• Next by Date: RE Looking for Gaussian Elimination Code
• Previous by thread: Re: Function
• Next by thread: Re: Function