MathGroup Archive 2008

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

Search the Archive

Indefinite numbers of arguments in a function

Hello everybody,
Is it possible to define a function in Mathematica, where the numbers of 
arguments does not matter?

I know the function Plus is defined like that:

I call the function with two arguments( for example Plus[5,3]) or I can 
call the function with five arguments (for example

How can i define a function in Mathematica like that? I know I can 
define for ever number of arguments a function like that:

I also know that I can create a list as one argument:

MyPlus[list_List] := (
  m = 0; For[n = 1, n < Length[list] + 1, n++, m += list[[n]] ];

But since there are functions like Plus, there has to be a way to define 
those kind of functions.

I would be very glad, if someone could give me his advice.

Best regards,

Patrick Klitzke

email:   philologos14 at

  • Prev by Date: Re: PolarPlot
  • Next by Date: Re: Numerical integration and list of points
  • Previous by thread: Re: SparseArray memory usage
  • Next by thread: Re: Indefinite numbers of arguments in a function