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.
Mathematica Stack Exchange is a question and answer site for users of Wolfram Mathematica. It only takes a minute to sign up.
Sign up to join this communityHere'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!)
$\endgroup$
– MarcoB
Mar 15 '16 at 3:43
With[]
?With[{p = 3}, HoldForm[p - 2]]
$\endgroup$ – J. M.'s ennui♦ Mar 15 '16 at 3:25