Re: How to evaluate parts of an expression, but not other parts?

• To: mathgroup at smc.vnet.net
• Subject: [mg122726] Re: How to evaluate parts of an expression, but not other parts?
• From: Alexey Popkov <lehin.p at gmail.com>
• Date: Tue, 8 Nov 2011 07:14:18 -0500 (EST)
• Delivered-to: l-mathgroup@mail-archive0.wolfram.com
• References: <j930l9\$a3d\$1@smc.vnet.net>

```Hi Julian,

http://stackoverflow.com/questions/6633236/replace-inside-held-expression

Two techniques are presented and discussed there:

1) The Trott-Strzebonski in-place evaluation technique

2) An undocumented, but very convenient, way to make replacements in
held expressions using RuleCondition:

In[3]:= Hold[{1, 2, 3, 4, 5}] /. n_Integer :> RuleCondition[n^2,
OddQ[n]]
Out[3]= Hold[{1, 2, 9, 4, 25}]

HTH,
Alexey

On 5 Nov, 13:46, Julian Francis <julian.w.francis at gmail.com> wrote:
> Dear all,
>
> I'd like to use the TreePlot function to visualise the expression of a
> dynamic programming problem I am working on.
>
> If I have something like: ( (a+b) + (c+d )
>
> Mathematica helpfully simplifies this to: a + b + c + d
>
> But I'd prefer it to be in the original form.
>
> I can't write Hold[ ( (a+b) + (c+d) )] because I do want a,b,c & d to
> be evaluated.
>
> I want to write something like:
> Hold[ ( (Evaluate[a]+Evaluate[b]) + (Evaluate[c]+Evaluate[d]) ) ]
>
> But this just leaves the Evaluate expressions unevaluated.
>
> Any help greatly appreciated.
>
> Thanks,
> Julian.

```

• Prev by Date: Re: Scoping of pattern names
• Next by Date: Re: Scoping of pattern names
• Previous by thread: Re: How to evaluate parts of an expression, but not other parts?
• Next by thread: Re: How to evaluate parts of an expression, but not other parts?