Let's assume a=b
, that is, a has value b. In a given expression like e.g.
a + i + HoldForm[a + k] + l
I would like to substitute - while the whole expression is being held globally - every symbol by its value, unless the symbol is wrapped in a local HoldForm. The form
HoldForm[a + i + HoldForm[a + k] + l] /. s_Symbol :> RuleCondition[s,ValueQ[s]]
returns b + i + (b + k) + l
,
that is, all symbols of the expression have been substituted by their values, including the second appearance of a. How can I identify symbols which are wrapped in a local HoldForm and exclude them from this substitution procedure? Or do I have to take a completely different approach?
Thanks for help!
Developer`ReplaceAllUnheld[Unevaluated[a + i + HoldForm[a + k] + l], s_Symbol :> RuleCondition[s, ValueQ[s]]]
would probably do the job. But what you ask is so incredibly clumsy, I recommend you rethink your code in the first place. $\endgroup$