Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2009

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

Search the Archive

Re: Help with HoldAll needed

  • To: mathgroup at smc.vnet.net
  • Subject: [mg100919] Re: Help with HoldAll needed
  • From: David Bailey <dave at removedbailey.co.uk>
  • Date: Thu, 18 Jun 2009 04:53:17 -0400 (EDT)
  • References: <h1aaej$8k1$1@smc.vnet.net>

Erich Neuwirth wrote:
> I define
> 
> MyFun[x_]:=Unevaluated[x]
> SetAttributes[MyFun,HoldAllComplete]
> 
> 
> MyFun[2 = 3]
> still evaluated the argument and of course produces an error
> I would like to get the unevaluated expression to be able
> to separate the first argument.
> 
> In fact, I would like MyFun to be a macro which allows me
> to play list processing games with the arguments.
> 
> How can this be accomplished?
> 
The best solution is to manipulate expressions wrapped in Hold or 
HoldForm (which does not show when the expression is printed). For 
example (using Hold)

In[13]:= lhs[expr_] := Extract[expr, {1, 1}, Hold];

In[15]:= expr = Hold[(3 + 2) = 2]

Out[15]= Hold[3 + 2 = 2]

In[16]:= lhs[expr]

Out[16]= Hold[3 + 2]

Notice that in my example the lhs is (3+2), and that this has not been 
evaluated.

David Bailey
http://www.dbaileyconsultancy.co.uk


  • Prev by Date: Re: PDF import problem
  • Next by Date: Re: PDF import problem
  • Previous by thread: Re: Help with HoldAll needed
  • Next by thread: Re: How to downsample a image matrix using left and right