Re: Functions with optional parameters
- To: mathgroup at smc.vnet.net
- Subject: [mg51961] Re: [mg51886] Functions with optional parameters
- From: Tomas Garza <tgarza01 at prodigy.net.mx>
- Date: Fri, 5 Nov 2004 02:19:50 -0500 (EST)
- References: <200411040649.BAA18109@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
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 In[13]:= 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 videotron.ca> To: mathgroup at smc.vnet.net 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 > >
- References:
- Functions with optional parameters
- From: Gregory Lypny <gregory.lypny@videotron.ca>
- Functions with optional parameters