Re: MatchQ, silly question
- To: mathgroup at smc.vnet.net
- Subject: [mg105130] Re: MatchQ, silly question
- From: janos <janostothmeister at gmail.com>
- Date: Sun, 22 Nov 2009 06:07:31 -0500 (EST)
- References: <he5v9i$3gh$1@smc.vnet.net> <he896k$q8g$1@smc.vnet.net>
An alternative solution from my student, Attila L=E1szl=F3 NAGY is:
MatchQ[3 x^2, #] & /@ {3 x_^2,
3 x_^_, _ x_^_, _ _Symbol^_, _ (_Symbol^_), _*(_Symbol^_)}
J=E1nos
**************************************************************************
On nov. 21, 09:43, David Bailey <d... at removedbailey.co.uk> wrote:
> janos wrote:
> > MatchQ[3 x^2, #] & /@ {3 x_^2, 3 x_^_, _ x_^_, _ _^_, _ (_^_), _ *
> > (_^_)}
>
> > dives False in the last cases. Why? The FullForm
>
> > Power[Blank[ ],Plus[1,Blank[ ]]]
>
> > contains Plus, why?
>
> > Thank you.
>
> > J=E1nos
>
> Because expressions still evaluate, even if they contain Blank[] - this
> can be easily seen by entering the expression _+_ .
>
> Wrap the pattern in HoldPattern to prevent evaluation.
>
> David Baileyhttp://www.dbaileyconsultancy.co.uk