Saving unsatisfied specific models

I often have to debug, preventing some determination from evaluating and checking intermediate results. I accomplished this by running initAll;clearAll[f,g,h] . I don't like it because

  • This forces you to put everything in one init block.
  • It is not flexible enough to save only certain patterns, such as f[1] unevaluated

Instead, I would like to have a list of forbidden patterns and have any pattern that does not match the previous one. How can I achieve this?

Edit So far I have found this model the most useful (this is Michael Pilate's answer, except for HoldForm and BlankNullSequence)

eh[expr_, symbols : {___Symbol}] := Block[symbols, HoldForm@Evaluate [expr]]

+4
source share
1 answer

Block can help with what you want:

 f[x_] := x + 1; g[x_] := x - 1; In[13]:= Block[{f}, Hold@Evaluate [(f[g[a]]^2)] ] Out[13]= Hold[f[-1 + a]^2] 

Do you want to prevent the evaluation of certain patterns while decreasing the cost of f ? (For example, block f[x_] , but allow f[x_, y_] )?

UPDATE

There is a functional form:

 SetAttributes[EvaluateHeld, HoldAll]; EvaluateHeld[expr_, symbols : {__Symbol}] := Block[symbols, Hold@Evaluate [expr] ] In[7]:= EvaluateHeld[f[g[a]]^2, {f}] Out[7]= Hold[f[-1 + a]^2] 
+3
source

All Articles