Re: basic issue with do and :=
- To: mathgroup at smc.vnet.net
- Subject: [mg60437] Re: [mg60402] basic issue with do and :=
- From: "W. Craig Carter" <ccarter at mit.edu>
- Date: Fri, 16 Sep 2005 03:49:51 -0400 (EDT)
- References: <200509150916.FAA15855@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
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
- References:
- basic issue with do and :=
- From: "David" <isolanoster@gmail.com>
- basic issue with do and :=