Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2004

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

Search the Archive

Re: Functions with optional parameters

  • To: mathgroup at
  • Subject: [mg51961] Re: [mg51886] Functions with optional parameters
  • From: Tomas Garza <tgarza01 at>
  • Date: Fri, 5 Nov 2004 02:19:50 -0500 (EST)
  • References: <>
  • Sender: owner-wri-mathgroup at

I'm not sure I get your question. If a, b, c, are numbers, then c cannot be 
empty.. It may be zero. Of course, if they are numbers, you may simply use
addThem[a_, b_, c_] := Plus @@ {a, b, c}

and it doesn't matter whether c is zero or not. In this problem, it is - 
IMO - unnecesary to define the function addThem, since it takes the same 
amount of typing as simply Plus@@. If you wish to use optional parameters in 
other situations, take a look at the Help browser under Optional.

Tomas Garza

Mexico City

----- Original Message ----- 
From: "Gregory Lypny" <gregory.lypny at>
To: mathgroup at
Subject: [mg51961] [mg51886] Functions with optional parameters

> Hello everyone,
> How can I create functions with optional parameters?  For example, a
> simple function to add two or three numbers:
> addThem[a_,b_,c_]:=If[c is not empty, Sum[a,b,c],Sum[a,b]]
> I'm not sure of the proper syntax to test whether c is null or empty.
> Greg

  • Prev by Date: Re: Counting Runs
  • Next by Date: Re: covariance, eigenvalues
  • Previous by thread: Functions with optional parameters
  • Next by thread: Re: Functions with optional parameters