When I do...
p=3;
HoldForm[Evaluate[p]-2]
I get:
Evaluate[p]-2
BUT I'd like to get:
3-2
How can I get this result? I want to display the subtraction, unevaluated -- but I want an expression within the subtraction to get evaluated.
When I do...
p=3;
HoldForm[Evaluate[p]-2]
I get:
Evaluate[p]-2
BUT I'd like to get:
3-2
How can I get this result? I want to display the subtraction, unevaluated -- but I want an expression within the subtraction to get evaluated.
Here's one way:
HoldForm[p - 2] /. HoldPattern[p] :> RuleCondition[p]
With method outlined by J.M. in your answer, since you found it useful as well. (+1 for self-answering!)
– MarcoB
Mar 15 '16 at 03:43
With[]?With[{p = 3}, HoldForm[p - 2]]– J. M.'s missing motivation Mar 15 '16 at 03:25