Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2010

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

Search the Archive

Re: Automatic update of variables

  • To: mathgroup at smc.vnet.net
  • Subject: [mg110314] Re: Automatic update of variables
  • From: "Sjoerd C. de Vries" <sjoerd.c.devries at gmail.com>
  • Date: Sun, 13 Jun 2010 04:09:41 -0400 (EDT)
  • References: <huvk4q$rq0$1@smc.vnet.net>

Are you kidding us? Using SetDelayed (:=) in the definition of b means
the most current value of a are used anytime b is used.

Check this:

b := a
a = 2;
b
a = 4;
b

yields 2, then 4.

Or try
b := a
Dynamic[b]

and the assign various values to a and see the dynamically displayed
value of b changing immediately.

By the way: b:=3 a +1 is not a delayed rule. That would be b:>3 a +1

Cheers -- Sjoerd

On Jun 12, 11:31 am, Antonio De Ju=E1rez <adejua... at 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.



  • Prev by Date: Re: Apply a function to parts of a list
  • Next by Date: Re: Lists: Row Vectors vs. Column Vectors. (feels like such a silly
  • Previous by thread: Re: Automatic update of variables
  • Next by thread: Re: Automatic update of variables