Re: problem with Mathematica

• To: mathgroup at christensen.cybernetics.net
• Subject: [mg493] Re: problem with Mathematica
• From: withoff (David Withoff)
• Date: Mon, 27 Feb 1995 10:52:03 -0600

```  I have a problem with Mathematica. I have looked for
this problem in MathGroup, but I haven't been successful yet. Maybe
you could point me some useful reference or put this problem on
MathGroup or explain the reason for following behavior:

In[1] :=  ClearAll[a, o, doit, done]

Out[1] =  o = a[2];

In[2] :=  a[_] := done /; doit

In[5] :=  doit = False;

If `doit' is set to `False' it works as I would expected only the
first time.

In[6] :=  Trace[o]

Out[6] =  {o, a[2], {{doit, False}, RuleCondition[done, False],
Fail}, a[2]}

The second time the delayed rule is not evaluated. Why?

In[7] :=  Trace[o]

Out[7] =  {o, a[2]}

Best Regards,
Pavel Krtous

-------------------------------------------

An explanation of this behavior can be found in the documentation
for the Update function in the Mathematica book (page 310 and page 892).

Expressions are evaluated only when something inside of the expression
has changed.  If you make a change to something that does not appear
anywhere in the expression, then you need to use Update.

In[1]:= o = a[2];

In[2]:= a[_] := done /; doit

In[3]:= doit = False;

In[4]:= Trace[o]

Out[4]= {o, a[2], {{doit, False}, RuleCondition[done, False], Fail}, a[2]}

In[5]:= Trace[o]

Out[5]= {o, a[2]}

In[6]:= Update[a]

In[7]:= Trace[o]

Out[7]= {o, a[2], {{doit, False}, RuleCondition[done, False], Fail}, a[2]}

Dave Withoff
Research and Development
Wolfram Research

```

• Prev by Date: Numerical Evaluation of HypergeometricPFQ
• Next by Date: PowerPC errata
• Previous by thread: Numerical Evaluation of HypergeometricPFQ
• Next by thread: Re: problem with Mathematica