[Date Index] [Thread Index] [Author Index]
Re: A variable defaulting to a previous variable?
Clear[f] f[x_] := f[x, x] f[x_, y_] := x + y f[2, 3] f 5 6 Bobby On Thu, 06 Oct 2011 03:25:54 -0500, Brentt <brenttnewman at gmail.com> wrote: > How would one go about making a variable default to a previous variable? > > I would like results like this: > > In= f[x_, y_: x] := x+y; >> In= f[2,3] >> Out= 5 >> In= f >> Out= 6 >> > > > > But, of course, Mathematica won't let me use a previous argument for the > default of the next argument. Is there a way to do this? -- DrMajorBob at yahoo.com