Re: Pattern gremlins.
- To: mathgroup at smc.vnet.net
- Subject: [mg55128] Re: Pattern gremlins.
- From: Josef Karthauser <joe at tao.org.uk>
- Date: Sun, 13 Mar 2005 04:57:47 -0500 (EST)
- References: <firstname.lastname@example.org> <005401c5271f$45b00480$6402a8c0@home>
- Sender: owner-wri-mathgroup at wolfram.com
On Sat, Mar 12, 2005 at 05:19:31PM +0100, wouter meeussen wrote: > you're close, real close. > > In:=a b c d e f g /. d f :> x > Out=a b c e g x > multiplication commutes, all possible pairs are tested, so d*f is found t= o match. But you knew that > already. But why use ":>" delayed if "->" suffices? The RHS is not up for= immediate interpretation > before the LHS is filled, now is it? So: > In:=a b c d e f g /. d f -> x > Out=a b c e g x > > Now, mind your precedences & brackets !! > In:=a b c d e f g /. x : d f :> u > Out=a b c d e f g > > boo, try again: > In:=a b c d e f g /. (x : d) f :> u > Out=a b c e g u > mmm, better, nah? > > and, vide supra: > In:=a b c d e f g /. (x : d) f -> u > Out=a b c e g u > > Cool software, I say! > > W. And so the point is I guess that, In:= a b c d e f g /. z:(d f) :> FOO[z] doesn't match, so instead I must do: In:= a b c d e f g /. (x:d) (y:f) :> FOO[x y] So by attaching a name, z, to z:(d f), this means that it would only find Times[d, f], and not any other times with other arguments also? Joe -- Josef Karthauser (joe at tao.org.uk) http://www.josef-k.net/ FreeBSD (cvs meister, admin and hacker) http://www.uk.FreeBSD.org/ Physics Particle Theory (student) http://www.pact.cpes.sussex.ac.uk/ ================ An eclectic mix of fact and theory. =================