Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2007

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

Search the Archive

Re: ReplaceAll question

  • To: mathgroup at smc.vnet.net
  • Subject: [mg82562] Re: ReplaceAll question
  • From: Albert <awnl at arcor.net>
  • Date: Wed, 24 Oct 2007 04:37:02 -0400 (EDT)
  • References: <ffkf46$sh6$1@smc.vnet.net>

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