MathGroup Archive 1996

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

Search the Archive

Re: Help on Function

  • To: mathgroup at
  • Subject: [mg3849] Re: Help on Function
  • From: ianc (Ian Collier)
  • Date: Mon, 29 Apr 1996 00:33:34 -0400
  • Organization: Wolfram Research, Inc.
  • Sender: owner-wri-mathgroup at

In article <4lesps$e4m at>, Roberto Diego
<roberto at> wrote:

> Hi people,
> Could you please help me? I4m trying to write a function (not procedure 
> if possible) that works on a list such as {a1, a2, a3, a4, ...} and 
> returns a list {a2/a1, a3/a2, a4/a3, ...}. I know it should be an easy 
> task but I4m a newbe...
> Thanks a lot

You can use Partition (with an offset of 1 specified as the third argument)
to divide your list up and then Map a suitable function across the list of

The following should do what you want:

    ls = {a1, a2, a3, a4, a5, a6}
    {a1, a2, a3, a4, a5, a6}

    f[ list_ ] := Map[ #[[2]]/#[[1]] &, Partition[ list, 2, 1 ]]

     a2  a3  a4  a5  a6
    {--, --, --, --, --}
     a1  a2  a3  a4  a5

I hope this helps.


Ian Collier
Wolfram Research, Inc.
tel:(217) 398-0700   fax:(217) 398-0747    ianc at
Wolfram Research Home Page:


  • Prev by Date: Animation problem
  • Next by Date: Not Sending To Remote Kernel
  • Previous by thread: RE: Help on Function
  • Next by thread: Re: Help on Function