MathGroup Archive 2011

[Date Index] [Thread Index] [Author Index]

Search the Archive

A variable defaulting to a previous variable?


How would one go about making a variable default to a previous variable?

I would like results like this:

In[1]= f[x_, y_: x] := x+y;
> In[2]= f[2,3]
> Out[1]= 5
> In[3]= f[3]
> Out[1]= 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?


  • Prev by Date: Re: can't find info about & /@ %
  • Next by Date: How to simplify a finite sum plus the next element?
  • Previous by thread: Re: How to use PDF for function definition?
  • Next by thread: Re: A variable defaulting to a previous variable?