Re: Transformation rules - explain please

• To: mathgroup at smc.vnet.net
• Subject: [mg74037] Re: [mg74023] Transformation rules - explain please
• From: "Chris Chiasson" <chris at chiasson.name>
• Date: Wed, 7 Mar 2007 03:10:20 -0500 (EST)
• References: <200703061032.FAA02186@smc.vnet.net>

```You might trying using == instead of =

On 3/6/07, wooks <wookiz at hotmail.com> wrote:
> This is supposed to substitute the first occurrence of old1 or old2
> with new.
>
> Why does this work
>
> Clear[old1, old, old2, lat, MySubst]
> lat = {banana, ice, cream, smeared, chocolate, topping};
> MySubst[new_, old1_, old2_, {x___, old_, r___}] := {x, new, r} /;
> Or[old == old1, old == old2];
> MySubst[strawberry, chocolate, cream, lat]
>
> but not this (with the conditional on the lhs).
>
> Clear[old1, old, old2, lat, MySubst]
> lat = {banana, ice, cream, smeared, chocolate, topping};
> MySubst[new_, old1_, old2_, {x___, old_, r___} /; Or[old = old1, old
> =  old2]] := {x, new, r};
> MySubst[strawberry, chocolate, cream, lat]
>
> I like the idea of using conditional rules like this but have found it
> very hit and miss. Often times things don't work so I am seeking
> further enlightment.
>
> I'd be interested to see what would need to be done to make the
> conditional work on the lhs.
>
>
>

--
http://chris.chiasson.name/

```

• Prev by Date: Re: Transformation rules - explain please
• Next by Date: Re: Transformation rules - explain please
• Previous by thread: Transformation rules - explain please
• Next by thread: Re: Transformation rules - explain please