I need to evaluate the result returned from an external package, which contains Defer
in it, but do this in a script without user interaction.
I am not able to figure how to do this, without actually using the mouse and hitting Shift + Return in the notebook itself. But I need to do this in a program (script) that runs outside the notebook environment.
Here is an example:
r = Defer[Integrate][Cos[x], x]
The out
cell there has the Defer in it. I want to now evaluate r
. The only way is by moving the mouse to the Out
cell and hit Enter, which now changes the Out
cell to an In
cell and evaluate what was there resulting in:
How do I do the above in a script? I tried Evaluate[r]
and Evaluate[ReleaseHold[r]]
and all sorts of things. But I can't get rid of the Defer
. (There is no RemoveDefer
function). The only way is to do evaluate in place which is what the pointing on the cell and hitting Enter does.
How do I remove Defer
from a returned expression and evaluate the result in non-interactive script (i.e. programmatically)?
I am using version 10.1 on Windows 7.
r /. Defer -> Identity
? $\endgroup$r/.Defer->Identity
? Wow, @ilian was 10 seconds faster! $\endgroup$