MathGroup Archive 2007

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

Search the Archive

Re: ReplaceAll question


Yaroslav Bulatov schrieb:
> b = 3;
> Hold[a[[b]]] /. {b -> c}
> 
> ReplaceAll has no effect, why? What is the recommended way of carrying
> out the replacement above?
> 
> 

the "b" in the rule is evaluated. Use HoldPattern:

In[1]:=
b = 3;
Hold[a[[b]]] /. {HoldPattern[b] -> c}

Out[2]= Hold[a[[c]]]

Peter


  • Prev by Date: Re: ReplaceAll question
  • Next by Date: Re: ReplaceAll question
  • Previous by thread: Re: ReplaceAll question
  • Next by thread: Re: ReplaceAll question