Re: Problem with matching.
- To: mathgroup at smc.vnet.net
- Subject: [mg53930] Re: [mg53907] Problem with matching.
- From: "Wolf, Hartmut" <Hartmut.Wolf at t-systems.com>
- Date: Fri, 4 Feb 2005 04:11:45 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
>-----Original Message----- >From: Josef Karthauser [mailto:joe at tao.org.uk] To: mathgroup at smc.vnet.net >Sent: Thursday, February 03, 2005 12:11 AM >To: mathgroup at smc.vnet.net >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? > >Thanks, >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. ================= > > > 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