MathGroup Archive 2006

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Seemingly strange behavior - HoldForm and Evaluate

  • To: mathgroup at smc.vnet.net
  • Subject: [mg68113] Re: [mg68109] Seemingly strange behavior - HoldForm and Evaluate
  • From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
  • Date: Mon, 24 Jul 2006 05:52:22 -0400 (EDT)
  • References: <200607240455.AAA25347@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

On 24 Jul 2006, at 06:55, Bharat Bhole wrote:

> I came across this when answering one of the queries posted on this  
> forum.
>
> If I write
>
> (1)
> In: a = 2;
>      HoldForm[a]
>
> Out: a
>
> (2)
> In: a=2;
>      HoldForm[Evaluate[a]]
>
> Out: 2
>
> (3) In: a=2;
>          b=3;
>          HoldForm[Evaluate[a] + Evaluate[b]]
>
> Out: Evaluate[a] + Evaluate[b]
>
>
>
> Example 2 seems to suggest that Evaluate works as expected, i.e., it
> evaluates the expression assigns value 2 despite the HoldAll  
> attribute of
> HoldForm. However, in example 3, evaluate does not function as  
> expected, or
> may it does, but I do not understand why a and b are not assigned  
> there
> values.
>
> Thanks,
> Bharat.
>
>

Reading documentation can save time and effort.

 From the documentation for Evaluate:

Evaluate only overrides HoldFirst, etc. attributes when it appears  
directly as the head of the function argument that would otherwise be  
held.

The behaviour you say you do not understand involves:

HoldForm[Plus[Evaluate[a], Evaluate[b]]]

HoldForm has attribute HoldALl and Evaluate does not appear directly  
as head of the argument that would be held (Plus is that head).

Andrzej Kozlowski


  • Prev by Date: Re: HoldForm
  • Next by Date: Re: word
  • Previous by thread: Seemingly strange behavior - HoldForm and Evaluate
  • Next by thread: RE: Seemingly strange behavior - HoldForm and Evaluate