Re: powersum with a function with variable count of parameters
- To: mathgroup at smc.vnet.net
- Subject: [mg25289] Re: powersum with a function with variable count of parameters
- From: Albert Retey <albert.retey at visualanalysis.com>
- Date: Tue, 19 Sep 2000 03:45:13 -0400 (EDT)
- Organization: Visual Analysis
- References: <8q22cs$hr0@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
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