From: Bob Hanlon on

b == Dynamic[3 a + 1]


Bob Hanlon

---- "Antonio De Ju=C3=A1rez" <adejuarez(a)gmail.com> wrote:

==========================
Sometimes, I would find useful a method to update variables
automatically. For example, given the delayed rule

b:==3 a+1;

it would be useful to have b updated whenever a is assigned a new
value, like a==37. Is there any method to do this in Mathematica?

Thanks,

Antonio.



From: Bill Rowe on
On 6/12/10 at 5:31 AM, adejuarez(a)gmail.com (Antonio De Ju=C3=A1rez) wrote:

>Sometimes, I would find useful a method to update variables
>automatically. For example, given the delayed rule

>b:=3 a+1;

>it would be useful to have b updated whenever a is assigned a new
>value, like a=37. Is there any method to do this in Mathematica?

Given:

In[11]:= b := 3 a + 1

In[12]:= a = 3; b

Out[12]= 10

In[13]:= a = 30; b

Out[13]= 91

It seems SetDelayed is doing precisely what you are requesting.