MathGroup Archive 2007

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

Search the Archive

Re: Replacement question

  • To: mathgroup at
  • Subject: [mg74193] Re: Replacement question
  • From: Jean-Marc Gulliet <jeanmarc.gulliet at>
  • Date: Wed, 14 Mar 2007 03:44:35 -0500 (EST)
  • Organization: The Open University, Milton Keynes, UK
  • References: <et5nnh$jhk$>

Brian Beckage wrote:
> I apologize for this very basic question.  I understand how to use /. 
> {} to replace a  variable with a more complex expression, e.g., x-> 
> y+z.  Can one move in the opposite direction to replace all 
> occurrences of y+z with x?   myExpression/.{y+z->x} does not seem to 
> work.

That works:

expr = z + y + a + b + 2*c + 2*d;
expr /. y + z -> x

a + b + 2 c + 2 d + x

Now, could you, please, post an example of an expression for which the 
replacement rule does not work?


  • Prev by Date: Re: Interpolating Function
  • Next by Date: Re: Noob evaluation question
  • Previous by thread: Re: Replacement question
  • Next by thread: Re: Replacement question