MathGroup Archive 1996

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

Search the Archive

Re: Help on Function


Roberto Diego asks:

> 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, ...}. 




In[1]:=
  f[X_List] := Map[Apply[Divide, #]&, 

                   Transpose[{Rest[X], Drop[X, -1],}]]
In[2]:=
  stuff = {a1, a2, a3, a4, a5}
Out[2]=
  {a1, a2, a3, a4, a5}
In[3]:=
  f[stuff]
Out[3]=
   a2  a3  a4  a5
  {--, --, --, --}
   a1  a3  a3  a4


--Lou Talman
  Metropolitan State College of Denver

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


  • Next by Date: Re: Function
  • Next by thread: Re: Help on Function