Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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?

share|improve this question
add comment

2 Answers 2

up vote 3 down vote accepted

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)

share|improve this answer
add comment

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
share|improve this answer
    
I've fixed about comparison, and is their a way to do this for all cell, without wrapping in Dynamic explicitly? –  m0nhawk May 5 '13 at 8:39
    
@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. –  István Zachar May 5 '13 at 8:49
    
@m0nhawk Just as what István Zachar has pointed out. (At least I failed to find one 囧. ) –  xzczd May 5 '13 at 9:01
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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