MathGroup Archive 2004

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

Search the Archive

Re: Length of actual parameters in a function call.


In article <c3udpe$9om$1 at smc.vnet.net>,
 "E. Martin-Serrano" <eMartinSerrano at houston.rr.com> wrote:

> A few weeks ago, reviewing some tutorials on pattern matching and error
> handling, I came across an undocumented function to monitor the number of
> parameters submitted to a function in a call; but somehow I lost its track
> later. I guess that it must be something well-known by our specialists. Any
> help about where to locate it?
> 
> The undocumented feature helps in tracking situations as when we define
> "MyFunction[a_,b_,c_]:= something" and then it is called as "myFunction[a]"
> leaving the function unevaluated.

  MyFunction[a_, b_, c_] := something

  MyFunction[args___] := Null /; Length[{args}] != 3 && 
    Message[MyFunction::argx, MyFunction, Length[{args}]]

  MyFunction[a]

Cheers,
Paul

-- 
Paul Abbott                                   Phone: +61 8 9380 2734
School of Physics, M013                         Fax: +61 8 9380 1014
The University of Western Australia      (CRICOS Provider No 00126G)         
35 Stirling Highway
Crawley WA 6009                      mailto:paul at physics.uwa.edu.au 
AUSTRALIA                            http://physics.uwa.edu.au/~paul


  • Prev by Date: Re: How to print large graphics cells?
  • Next by Date: Re: Yet another Mathematica docs whopper
  • Previous by thread: Re: Length of actual parameters in a function call.
  • Next by thread: Re: Re: Length of actual parameters in a function call.