Re: Functions with optional parameters
- To: mathgroup at smc.vnet.net
- Subject: [mg51955] Re: [mg51886] Functions with optional parameters
- From: Bob Hanlon <hanlonr at cox.net>
- Date: Fri, 5 Nov 2004 02:19:26 -0500 (EST)
- Reply-to: hanlonr at cox.net
- Sender: owner-wri-mathgroup at wolfram.com
addThem[a__] := Plus[a]; addThem[a,b,c] a + b + c addThem[a,b] a + b f1[x_,y_,z_] :=g[x,y,z]; f1[x_,y_]:= h[x,y]; f1[a,b,c] g[a, b, c] f1[a,b] h[a, b] To assign a default value f2[x_,y_,z_:d] := g[x,y,z]; f2[a,b,c] g[a, b, c] f2[a,b] g[a, b, d] Bob Hanlon > > From: Gregory Lypny <gregory.lypny at videotron.ca> To: mathgroup at smc.vnet.net > Date: 2004/11/04 Thu AM 01:49:57 EST > To: mathgroup at smc.vnet.net > Subject: [mg51955] [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 > >