Re: Functions with optional parameters
- To: mathgroup at smc.vnet.net
- Subject: [mg51921] Re: Functions with optional parameters
- From: "Jens-Peer Kuska" <kuska at informatik.uni-leipzig.de>
- Date: Fri, 5 Nov 2004 02:17:15 -0500 (EST)
- Organization: Uni Leipzig
- References: <cmclfa$i7s$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Hi, a) addThem[a_, b_, c_:Undefined] := If[Undefined === c, a + b, a + b + c] b) addThem[a__] := Plus[a] Regards Jens "Gregory Lypny" <gregory.lypny at videotron.ca> schrieb im Newsbeitrag news:cmclfa$i7s$1 at smc.vnet.net... > 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 >