MathGroup Archive 2005

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

Search the Archive

Re: writing a function with unknown number of paramters

  • To: mathgroup at smc.vnet.net
  • Subject: [mg60555] Re: [mg60519] writing a function with unknown number of paramters
  • From: "David Park" <djmp at earthlink.net>
  • Date: Tue, 20 Sep 2005 05:19:16 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

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