MathGroup Archive 2007

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

Search the Archive

Re: Releasing several Holds simultaneously


Andrew Moylan wrote:
> Hold[a := Hold[1]]
> 
> How can I release both of these Holds (and thus execute a:=1)
> simultaneously?
> 
> ReleaseHold[%] doesn't work; it evaluates a := Hold[1] before the other hold
> is removed.
> 

Hi Andrew,

How did you construct the expression Hold[a := Hold[1]]?  Perhaps there 
is a way to avoid the double Hold and construct Hold[a := 1] directly 
(even if there is an expression in place of '1' that must not be 
evaluated), using Unevaluated[].

> % /. Hold[x_]:>x does the same thing, because /. only matches once per part.
> 

If you use Replace instead of ReplaceAll, then you can specify the level 
at which the replacement should be done.

Replace[Hold[a := Hold[1]], Hold[x_] -> x, {2}]

-- 
Szabolcs


  • Prev by Date: RE: Releasing several Holds simultaneously
  • Next by Date: Re: Integers networks
  • Previous by thread: Re: Releasing several Holds simultaneously
  • Next by thread: Re: Releasing several Holds simultaneously