Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2005
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2005

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

Search the Archive

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: <d0u6kr$kl6$1@smc.vnet.net> <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[3]:=a b c d e f g /. d f :> x
> Out[3]=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[4]:=a b c d e f g /. d f -> x
> Out[4]=a b c e g x
>
> Now, mind your precedences & brackets !!
> In[5]:=a b c d e f g /. x : d f :> u
> Out[5]=a b c d e f g
>
> boo, try again:
> In[6]:=a b c d e f g /. (x : d) f :> u
> Out[6]=a b c e g u
> mmm, better, nah?
>
> and, vide supra:
> In[7]:=a b c d e f g /. (x : d) f -> u
> Out[7]=a b c e g u
>
> Cool software, I say!
>
> W.

And so the point is I guess that,

 In[1]:= a b c d e f g /. z:(d f) :> FOO[z]

doesn't match, so instead I must do:

 In[1]:= 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. =================



  • Prev by Date: Re: Simplfying inside Sqrt
  • Next by Date: Re: Simplfying inside Sqrt
  • Previous by thread: Pattern gremlins.
  • Next by thread: Re: Pattern gremlins.