I have the cells:

In[1]:= l = 2 + 2;

In[2]:= l >= 5

After evaluating them:

Out[2]:= False

Is there a way to evaluate all related cells, so if I change In[1] to l = 2 + 5, Out[2] would become True without evaluating the whole notebook?


2 Answers 2


Perhaps something along these lines could help?

$PrePrint= # /. 
         Except[Null] :> With[{line = $Line}, DynamicSetting@Dynamic@In[line]] /. 
    DownValues[In] &;

After running this, everything you evaluate is automatically wrapped in Dynamic so its value is updated automatically. I haven't tested it much so there may be issues.

(Be careful with endless dynamic updating loops)


You can try Dynamic(by the way, l = 2 + 5 won't make l >= 5 to be False…):

In[20]:= l = 1 + 3

Out[20]= 4

In[19]:= Dynamic[l >= 5]

Out[19]= False
  • $\begingroup$ I've fixed about comparison, and is their a way to do this for all cell, without wrapping in Dynamic explicitly? $\endgroup$
    – m0nhawk
    Commented May 5, 2013 at 8:39
  • $\begingroup$ @m0nhawk No other easy way. You either tell each related cell to listen to a dynamic value by wrapping their contents in Dynamic OR you re-evaluate these cells. You can play with cell options, but Mathematica will never figure out on its own which cells it should update and which cells it shouldn't. $\endgroup$ Commented May 5, 2013 at 8:49
  • $\begingroup$ @m0nhawk Just as what István Zachar has pointed out. (At least I failed to find one 囧. ) $\endgroup$
    – xzczd
    Commented May 5, 2013 at 9:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.