Hey guys,
Is there any way to put expressions to be executed automatically when the notebook starts? For example, among others, I would like the following code to run when a notebook is opened:
ClearAttributes[If, HoldRest]
Regards,
Sinval
Hey guys,
Is there any way to put expressions to be executed automatically when the notebook starts? For example, among others, I would like the following code to run when a notebook is opened:
ClearAttributes[If, HoldRest]
Regards,
Sinval
You can make cells into Initialization Cells via Cell->Cell Properties.
Having said that, it strikes me as a very bad idea to clear the HoldRest property of If.
You can look at NotebookDynamicExpression.
But I echo the comment by Eric, it would be an exceedingly, and perhaps, fatal mistake to make those changes to the If statement. To misquote, Shakespeare: there are more things in heaven and If than are dreamt of in your philosophy…
There are huge amounts of Mathematica code behind the scenes, running things. And if you change that attribute, it’s likely that your entire universe will collapse around you. Be careful out there it’s wild.
Thanks to Eric and David for the alert and information. I will review this procedure.
On a side note, if you want a version of If[] without the HoldRest attribute to use only in your notebook’s code, just define one. For example:
IfUnheld = If[##] &;
Thanks Michael for the tip. I will try this procedure as well.