MathGroup Archive 2005

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

Search the Archive

Re: basic issue with do and :=


On Thu, 15 Sep 2005, David wrote:

> While this doesn't:
>
> --------------------------
> Do[a[i] = i, {i, 10}]
> Do[b[i] :=a[i]+1, {i, 10}]
> ---------------------------
>
> [note ":=" instead of "=" on the second line].


Hmmm, I can't quite see what you are after here. Do you want to 
change the values of a[i] afterwards and have them appear in b? If 
so, why not include an argument for a in b.

In any case, if you do this
Do[a[i] = i, {i, 10}]
Do[b[i_] := a[i] + 1, {i, 10}]
(The second do contains 9 redundant definitions!!!!!!!!!)
Then,
b[6] will be 7,
b[23] will be 1 + a[23]
and
a[2] = YooHoo;
b[2] will be 2 + YooHoo


  • Prev by Date: Re: Mathematica: access serial port?
  • Next by Date: NonlinearFit - Logistic Function-CalcCenter3
  • Previous by thread: basic issue with do and :=
  • Next by thread: Re: basic issue with do and :=