MathGroup Archive 2007

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

Search the Archive

Re: Releasing several Holds simultaneously


Hi,

I love such questions ! Try:

RemoveInnerHold[expr_] :=
  Module[{syms, rep, nexpr},
   syms = Cases[expr,
     Except[Hold | HoldComplete | HoldPattern | HoldForm, _Symbol],
     Infinity, Heads -> True];

   rep = Thread[syms -> Table[Unique[], {Length[syms]}]];
   nexpr = (expr /. rep) //. Hold[any_] :> any;
   nexpr /. (Reverse /@ rep)
   ]

while
Hold[Hold[q] + Hold[c] + Hold[2 + 3 + 4]] // ReleaseHold
gives
Hold[2 + 3 + 4] + Hold[c] + Hold[q]

but

RemoveInnerHold[Hold[Hold[q] + Hold[c] + Hold[2 + 3 + 4]]]

gives

9+c+q

Regards
   Jens


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.
> 
> 


  • Prev by Date: Re: Transparently passing on options to other functions
  • Next by Date: Re: Help with NMinimize
  • Previous by thread: RE: Releasing several Holds simultaneously
  • Next by thread: Re: Releasing several Holds simultaneously