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: [mg82534] Re: ReplaceAll question
  • From: Peter Pein <petsie at dordos.net>
  • Date: Wed, 24 Oct 2007 04:22:41 -0400 (EDT)
  • References: <ffkf46$sh6$1@smc.vnet.net>

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