Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2005
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2005

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

Search the Archive

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


  • 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 :=