Re: Question on defaults in positional arguments
- To: mathgroup at smc.vnet.net
- Subject: [mg112593] Re: Question on defaults in positional arguments
- From: "David Park" <djmpark at comcast.net>
- Date: Wed, 22 Sep 2010 01:56:35 -0400 (EDT)
If Mathematica cannot distinguish between the arguments by their types, then you must include all the leading optional arguments of the same type. Clear[f]; f[x_: 1, y_: 2, z_: 3] := {x, y, z} f[1, 5] {1, 5, 3} But... Clear[f] f[x_String: "Type1", y_Integer: 2, z_Real: 3.0] := {x, y, z} f[5] {"Type1", 5, 3.} David Park djmpark at comcast.net http://home.comcast.net/~djmpark/ From: NP [mailto:nomplume69 at gmail.com] Hi, I was wondering if there was a way in selectively specifying some of the arguments of a function (rest remaining default). For instance, consider Clear[f, x, y,z]; f[x_: 1, y_: 2,z_:3] := {x, y} f[5] {5,2,3} Here the default values of y and z are automatically used. How can I call f so that, for example, the default value of x and z are used instead? Thanks, NP