MathGroup Archive 2006

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

Search the Archive

RE: Condition in replacement rule

  • To: mathgroup at smc.vnet.net
  • Subject: [mg67784] RE: [mg67736] Condition in replacement rule
  • From: "David Park" <djmp at earthlink.net>
  • Date: Fri, 7 Jul 2006 07:13:21 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

Mathematica cannot determine whether V is equal to W. What it can determine
is that the expression is not the same. This is given by the UnsameQ
operator,
=!=.

rule = A[V, W_ /; W =!= V] -> A[V, W] + B[W]

A[V, W] /. rule
A[V, W] + B[W]

A[V, V] /. rule
A[V, V]

It is also generally better to start your symbol names with lower case
letters to avoid conflicts with Mathematica defined symbols.

David Park
djmp at earthlink.net
http://home.earthlink.net/~djmp/


From: wandering.the.cosmos at gmail.com
To: mathgroup at smc.vnet.net
[mailto:wandering.the.cosmos at gmail.com]

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: Beginner--How to get a positive solution from Solve Command
  • Next by Date: RE: Repost --- Another limit problem
  • Previous by thread: Re: Condition in replacement rule
  • Next by thread: Re: Condition in replacement rule