Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #5513
| From | DrMajorBob <btreat1@austin.rr.com> |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | Re: A variable defaulting to a previous variable? |
| Date | 2011-10-07 08:59 +0000 |
| Organization | Steven M. Christensen and Associates, Inc and MathTensor, Inc. |
| Message-ID | <j6mf23$7gs$1@smc.vnet.net> (permalink) |
| References | <201110060825.EAA22765@smc.vnet.net> |
Clear[f] f[x_] := f[x, x] f[x_, y_] := x + y f[2, 3] f[3] 5 6 Bobby On Thu, 06 Oct 2011 03:25:54 -0500, Brentt <brenttnewman@gmail.com> wrote: > 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? -- DrMajorBob@yahoo.com
Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread
Re: A variable defaulting to a previous variable? DrMajorBob <btreat1@austin.rr.com> - 2011-10-07 08:59 +0000
csiph-web