MathGroup Archive 2010

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

Search the Archive

Re: Automatic update of variables

  • To: mathgroup at smc.vnet.net
  • Subject: [mg110327] Re: Automatic update of variables
  • From: Erik Max Francis <max at alcyone.com>
  • Date: Sun, 13 Jun 2010 04:12:02 -0400 (EDT)
  • References: <huvk4q$rq0$1@smc.vnet.net>

Antonio De Ju=E1rez 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?

I don't really follow the goal of what you're doing here.  Using `:=`
for assignment explicitly means that you do _not_ want the right-hand
side of the expression evaluated.  If `b` depends on `a` then the
sensible thing to do here is to make `b` a function:

	b[a_] := 3 a + 1;

and then do the appropriate substitute `b[somethingOrOther]` when the
time is right.

The only other thing I can think of that you might be trying to get at
would be `Dynamic`, which you can look up.

Perhaps if you said more about the problem you're trying to solve more
generally, people could suggest a more appropriate solution.

--
Erik Max Francis && max at alcyone.com && http://www.alcyone.com/max/
  San Jose, CA, USA && 37 18 N 121 57 W && AIM/Y!M/Skype erikmaxfrancis
   War is like love, it always finds a way.
    -- Bertolt Brecht


  • Prev by Date: Re: Find value of unknown const that causes integral to equal some
  • Next by Date: Re: Find value of unknown const that causes integral to equal some value
  • Previous by thread: Re: Automatic update of variables
  • Next by thread: Automatic update of variables