MathGroup Archive 2007

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

Search the Archive

RE: Releasing several Holds simultaneously

  • To: mathgroup at smc.vnet.net
  • Subject: [mg82300] RE: Releasing several Holds simultaneously
  • From: "Andrew Moylan" <andrew.j.moylan at gmail.com>
  • Date: Wed, 17 Oct 2007 04:01:09 -0400 (EDT)
  • References: <ff1po5$90n$1@smc.vnet.net> <4714B636.7010506@gmail.com>

Thanks Szabolcs!

Replace[expr, Hold[e___] :> e, {0, Infinity}, Heads -> True]

is is the answer I'm looking for. I had tried

ReplaceAll[expr, Hold[e___] :> e, {0, Infinity}, Heads -> True]

which is insufficient because of this property of ReplaceAll
(ref/ReplaceAll):

"The first rule that applies to a particular part is used; no further rules
are tried on that part, or on any of its subparts."

I failed to think of Replace at all.


-----Original Message-----
From: Szabolcs Horv=E1t [mailto:szhorvat at gmail.com]
Sent: Tuesday, 16 October 2007 11:02 PM
To: Andrew Moylan
Subject: [mg82300] 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.
>
> % /. Hold[x_]:>x does the same thing, because /. only matches once per
part.

This should work for releasing all Holds in expr:

Replace[expr, Hold[e___] :> e, {0, Infinity}, Heads -> True]

--
Szabolcs



  • Prev by Date: Re: Help with NMinimize
  • Next by Date: Re: Releasing several Holds simultaneously
  • Previous by thread: Re: Releasing several Holds simultaneously
  • Next by thread: RE: Releasing several Holds simultaneously