A variable defaulting to a previous variable?
- To: mathgroup at smc.vnet.net
- Subject: [mg121920] A variable defaulting to a previous variable?
- From: Brentt <brenttnewman at gmail.com>
- Date: Thu, 6 Oct 2011 04:25:54 -0400 (EDT)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
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?
- Follow-Ups:
- Re: A variable defaulting to a previous variable?
- From: Leonid Shifrin <lshifr@gmail.com>
- Re: A variable defaulting to a previous variable?
- From: DrMajorBob <btreat1@austin.rr.com>
- Re: A variable defaulting to a previous variable?