MathGroup Archive 2005

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

Search the Archive

Re: writing a function with unknown number of paramters

On 9/19/05 at 4:45 AM, someonekicked at (Someonekicked)

>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.

Note, there is a difference between a function with an unknown number of arguements and a function accepting a List of unknown length. 

Suppose I wanted to get the trace of several matrices. One way would be


Generate some data and test

matA = Table[Random[], {3}, {3}]; 
matB = Table[Random[], {4}, {4}]; 
myTr[{matA, matB}]

{1.4689092118145766, 0.6890047681388858}

An alternate means of achieve exactly the same thing would be to allow an arbitrary number of matrices as arguements to the function, i.e.,

myTr2[matA, matB]

{1.4689092118145766, 0.6890047681388858}
To reply via email subtract one hundred and four

  • Prev by Date: Re: Differences between recursions and limit
  • Next by Date: Re: 5.2 Install issues
  • Previous by thread: Re: writing a function with unknown number of paramters
  • Next by thread: Running ps2pdf from within Mathematica