MathGroup Archive 2006

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

Search the Archive

Re: Condition in replacement rule

  • To: mathgroup at smc.vnet.net
  • Subject: [mg67773] Re: [mg67736] Condition in replacement rule
  • From: Bob Hanlon <hanlonr at cox.net>
  • Date: Fri, 7 Jul 2006 07:12:44 -0400 (EDT)
  • Reply-to: hanlonr at cox.net
  • Sender: owner-wri-mathgroup at wolfram.com

{A[V,W],A[V,V],A[V,x]}/.
  A[V,W_/;Not[W===V]] -> A[V,W] + B[W]

{A(V,W)+B(W),A(V,V),A(V,x)+B(x)}

{A[V,W],A[V,V],A[V,x]}/.
  A[V,W_]/;W=!=V -> A[V,W] + B[W]

{A(V,W)+B(W),A(V,V),A(V,x)+B(x)}

{A[V,W],A[V,V],A[V,x]}/.
  A[V,W_?(#=!=V&)] -> A[V,W] + B[W]

{A(V,W)+B(W),A(V,V),A(V,x)+B(x)}


Bob Hanlon

---- "wandering.the.cosmos at gmail.com" <wandering.the.cosmos at gmail.com> wrote: 
> I have a replacement rule that goes like
> 
> A[V,W_] -> A[V,W] + B[W]
> 
> but I want to perform this replacement if and only if V and W are not
> the same. It seems
> 
> A[V,W_/;W!=V] -> A[V,W] + B[W]
> 
> does not seem to work. How should I do this?
> 
> Thanks!
> 


  • Prev by Date: RE:Simplest question: How to control some values in Input dialog box
  • Next by Date: Beginner--How to get a positive solution from Solve Command
  • Previous by thread: Re: Condition in replacement rule
  • Next by thread: RE: Condition in replacement rule