MathGroup Archive 2000

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

Search the Archive

Re: powersum with a function with variable count of parameters


Hi Peter,

> how can I write a function f[x_,xi__]=10^x+10^xi, 

first of all you should use ":=" instead of "=" so that the rhs is not
evaluated right away, but only when you call the function (See any
introduction to Mathematica for this).

One possibility to achieve what you want would be:

f[x__] := Apply[Plus, Map[10^# &, {x}]];

If you don't understand this code have a look at the documentation of
pure functions as well as Apply and Map.

hope it helps,
Albert


  • Prev by Date: RE: powersum with a function with variable count of parameters
  • Next by Date: Re: powersum with a function with variable count of parameters
  • Previous by thread: RE: powersum with a function with variable count of parameters
  • Next by thread: Re: powersum with a function with variable count of parameters