4

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.

Sean
  • 535
  • 4
  • 10

1 Answers1

5

Here's one way:

HoldForm[p - 2] /. HoldPattern[p] :> RuleCondition[p]
Sean
  • 535
  • 4
  • 10
  • Found after some deeper digging into comments of this question: http://mathematica.stackexchange.com/questions/75260/how-to-evaluate-some-parts-of-an-expression-inside-hold – Sean Mar 15 '16 at 03:24
  • 4
    Sean, perhaps you could add the 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