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: [mg60436] Re: basic issue with do and :=
  • From: "Jens-Peer Kuska" <kuska at informatik.uni-leipzig.de>
  • Date: Fri, 16 Sep 2005 03:49:47 -0400 (EDT)
  • Organization: Uni Leipzig
  • References: <dgbevg$fol$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Hi,

a = b

evaluates b with out delay,

a:=b

evaluates b every time when a "a" symbol appear in
your expression. In your second example you set 
only
the definition that b[i] is equal to the symbolic
expression a[i]+1.
You may try
(a[#] = # ) & /@ Range[1, 10];

b[i_Integer] /; 1<=i<=10:=a[i]+1

Regards

   Jens



"David" <isolanoster at gmail.com> schrieb im 
Newsbeitrag news:dgbevg$fol$1 at smc.vnet.net...
| Hi all,
|
| this works as (I) expected
|
| -------------------------
| Do[a[i] = i, {i, 10}]
| Do[b[i] =a[i]+1, {i, 10}]
| -------------------------
|
| 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].
|
| namely the output is: "b[2]:=a[i]+1" for all i
|
|
|
| Is there any compact way to define: "b[i] 
:=a[i]+1" for all i ?
|
|
| Thank you in advance,
|
| David
| 



  • Prev by Date: Re: Other Way than Print[] for Intermediate Results
  • Next by Date: Re: basic issue with do and :=
  • Previous by thread: Re: basic issue with do and :=
  • Next by thread: Re: basic issue with do and :=