MathGroup Archive 2005

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

Search the Archive

Re: Problem with matching.

  • To: mathgroup at smc.vnet.net
  • Subject: [mg54017] Re: [mg53907] Problem with matching.
  • From: Josef Karthauser <joe at tao.org.uk>
  • Date: Mon, 7 Feb 2005 03:13:18 -0500 (EST)
  • References: <200502040911.EAA00959@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Thanks to everyone who had suggestions to address my matching
problem.

The boiled down wisdom is that in the case where a pattern doesn't
appear to match in the way expected, e.g.. in MatchQ[expr,pattern],
make use of both 'expr//FullForm' and 'pattern//FullForm' to make
sure that both the expression and the pattern are really in the
form that you expect, because other rules might have had a chance
to rewrite them before they get applied.  Copious amounts of
'HoldPattern[pattern]' might be necessary to get the expected behaviour.

Rgds,
Joe

On Fri, Feb 04, 2005 at 04:11:08AM -0500, Bob Hanlon wrote:
> F[{___,a_,___}]F[{___,a_,___}]//FullForm
>
> Power[F[List[BlankNullSequence[],Pattern[a,Blank[]],BlankNullSequence[]]],2]
>
> The two terms on the LHS of the rule are identical so they are multiplied to
> form F^2.  Use the following:
>
> F[{x,2,c}]F[{x,1,f}]/.F[{___,a_,___}]F[{___,b_,___}]/;a==b:>yes
>
> yes
>
>
> Bob Hanlon
>
> >
> > From: Josef Karthauser <joe at tao.org.uk>
To: mathgroup at smc.vnet.net
> > Date: 2005/02/02 Wed PM 06:10:51 EST
> > To: mathgroup at smc.vnet.net
> > Subject: [mg54017] [mg53913] [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. =================



  • Prev by Date: Re: Finding extra digit
  • Next by Date: Re: Re: Contour Integration
  • Previous by thread: Re: Problem with matching.
  • Next by thread: Re: Problem with matching.