Re: Releasing several Holds simultaneously
- To: mathgroup at smc.vnet.net
- Subject: [mg82268] Re: Releasing several Holds simultaneously
- From: Szabolcs Horvát <szhorvat at gmail.com>
- Date: Wed, 17 Oct 2007 03:44:45 -0400 (EDT)
- References: <ff1po5$90n$1@smc.vnet.net>
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