Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #5513 > unrolled thread

Re: A variable defaulting to a previous variable?

Started byDrMajorBob <btreat1@austin.rr.com>
First post2011-10-07 08:59 +0000
Last post2011-10-07 08:59 +0000
Articles 1 — 1 participant

Back to article view | Back to comp.soft-sys.math.mathematica

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: A variable defaulting to a previous variable? DrMajorBob <btreat1@austin.rr.com> - 2011-10-07 08:59 +0000

#5513 — Re: A variable defaulting to a previous variable?

FromDrMajorBob <btreat1@austin.rr.com>
Date2011-10-07 08:59 +0000
SubjectRe: A variable defaulting to a previous variable?
Message-ID<j6mf23$7gs$1@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

[toc] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web