RuleCondition provides an undocumented, but very convenient, way to make replacements in held expressions. For example, if we want to square the odd integers in a held list:
In[3]:= Hold[{1, 2, 3, 4, 5}] /. n_Integer :> RuleCondition[n^2, OddQ[n]] Out[3]=(* Hold[{1, 2, 9, 4, 25}] *) RuleCondition differs from Condition in that the replacement expression is evaluated before it is substituted. The second argument of RuleCondition may be omitted, defaulting to True:
In[4]:= Hold[{2., 3.}] /. n_Real :> RuleCondition[n^2] Out[4]=(* Hold[{4., 9.}] *) It is very unfortunate that RuleCondition has remained undocumented for so long, given its extreme usefulness. The Trott-Strzebonski trick discussed in @Leonid's answer is one way to achieve the same result using only documented symbols:
In[5]:= Hold[{2., 3.}] /. n_Real :> With[{eval = n^2}, eval /; True] Out[5]=(* Hold[{4., 9.}] *) A slightly less verbose technique uses Block:
In[6]:= Hold[{2., 3.}] /. n_Real :> Block[{}, n^2 /; True] Out[6]=(* Hold[{4., 9.}] *) Judicious use of Trace reveals that both of these techniques ultimately resolve to RuleCondition. One must make up one's mind whether it is better to use the undocumented RuleCondition or rely upon implementation artifacts in With and Block. I suspect that the behaviour is unlikely to change in all three cases as so much MathematicaMathematica code depends upon the existing behaviour.