MathGroup Archive 2005

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

Search the Archive

Re: Problem with matching.

  • To: mathgroup at
  • Subject: [mg53930] Re: [mg53907] Problem with matching.
  • From: "Wolf, Hartmut" <Hartmut.Wolf at>
  • Date: Fri, 4 Feb 2005 04:11:45 -0500 (EST)
  • Sender: owner-wri-mathgroup at

>-----Original Message-----
>From: Josef Karthauser [mailto:joe at] 
To: mathgroup at
>Sent: Thursday, February 03, 2005 12:11 AM
>To: mathgroup at
>Subject: [mg53930] [mg53907] Problem with matching.
>Can someone tell me why this doesn't match?
>F[{x, 2, c}]F[{x, 1, f}] /. F[{___, a_, ___}]F[{___, a_, ___}] :> yes
>I'm expecting 'yes' to be returned if any of the list 
>arguments to F[] contain the same value.  It doesn't match 
>however; what am I doing wrong?
>Josef Karthauser (joe at
>FreeBSD (cvs meister, admin and hacker)
>Physics Particle Theory (student)
>================ An eclectic mix of fact and theory. =================

In[2]:= F[{x,2,c}]F[{x,1,f}] /.
	HoldPattern[F[{___,a_,___}]F[{___,a_,___}]] :> yes

Out[2]= yes

The first argument of Rule or RuleDelayed is evaluated before
application of the rule. HoldPattern prevents this.

Such your pattern first became 

In[3]:= F[{___, a_, ___}]F[{___, a_, ___}]

Out[3]= F[{___, a_, ___}]^2

which then of course didn't match.

Hartmut Wolf

  • Prev by Date: Re: Problem with matching.
  • Next by Date: Re: Problem with matching.
  • Previous by thread: Re: Problem with matching.
  • Next by thread: Re: Problem with matching.