MathGroup Archive 2007

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

Search the Archive

Re: ReplaceAll question


Yaroslav Bulatov wrote:
> b = 3;
> Hold[a[[b]]] /. {b -> c}
> 
> ReplaceAll has no effect, why? 

Because the rule b -> c is evaluated to 3 -> c
before it is applied, and the latter doesn't
match anything, which at least is better than
to match something that shouldn't...

> What is the recommended way of carrying
> out the replacement above?

Hold[a[[b]]] /. {HoldPattern[b] -> c}

hth,

albert


  • Prev by Date: remove whitespace
  • Next by Date: (x|y) \[element] Integers in Reduce function
  • Previous by thread: Re: ReplaceAll question
  • Next by thread: Re: ReplaceAll question