Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #6226 > unrolled thread

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

Started byAndrzej Kozlowski <akoz@mimuw.edu.pl>
First post2011-11-06 11:00 +0000
Last post2011-11-06 11:00 +0000
Articles 1 — 1 participant

Back to article view | Back to comp.soft-sys.math.mathematica

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: How to evaluate parts of an expression, but not other parts? Andrzej Kozlowski <akoz@mimuw.edu.pl> - 2011-11-06 11:00 +0000

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

FromAndrzej Kozlowski <akoz@mimuw.edu.pl>
Date2011-11-06 11:00 +0000
SubjectRe: How to evaluate parts of an expression, but not other parts?
Message-ID<j95pc8$m7l$1@smc.vnet.net>
On 5 Nov 2011, at 10:45, Julian Francis 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.
>


Well, there may be a simpler way, but here is one that comes to my mind:

a = x; b = y; c = z; d = w;

HoldForm @@ Apply[Hold, Hold[(a + b) + (c + d)], {2}] /. p_Hold :> With[{w = Plus @@ p}, w /; True]

HoldForm[(x + y) + (w + z)]

Andrzej Kozlowski=

[toc] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web