Is it possible to find the values of variables of a running Mathematica evaluation, without interrupting it? For example, suppose I do:
Do[Pause[1]; a++, {50}]
and then afterwards realize that the code is taking a long time. If I had realized before the computation started that it would be slow, I could have initially evaluated Dynamic[a], and then run the computation. Is there any way to do something similar after the computation has started, without interrupting the computation?
Answer
For simplistic purposes there is Evaluate in Subsession which is in the Evaluation menu, and has the shortcut key F7 under Windows & Linux (and alt+shift+enter under macOS).
Simply make a new Cell while the evaluation is running, containing e.g. a, make sure the cell has focus, and press F7; Mathematica evaluates this and returns the current value of a, and continues the computation.
If you prefer an ongoing count you can put e.g. Dynamic[a] in the new cell.

Comments
Post a Comment