MathGroup Archive 2005

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

Search the Archive

Re: writing a function with unknown number of paramters


Here is an example...

addthem[terms__] := Plus @@ {terms}

addthem[a, b]
a + b

addthem[a, b, c, d]
a + b + c + d

The double blank on the terms pattern indicates one or more items.

David Park
djmp at earthlink.net
http://home.earthlink.net/~djmp/ 


From: Someonekicked [mailto:someonekicked at comcast.net]
To: mathgroup at smc.vnet.net

I wanna write a function that can take an unknown number of parameters in 
mathematica, how I can do that??


For example, The built-in function Plot,

Plot[{f1,f2,f3. }, {x, xmin, xmax}]

can take an unknown number of functions then plot them.




  • Prev by Date: Re: writing a function with unknown number of paramters
  • Next by Date: Re: Running ps2pdf from within Mathematica
  • Previous by thread: Re: writing a function with unknown number of paramters
  • Next by thread: Re: writing a function with unknown number of paramters