Re: MatchQ, silly question
- To: mathgroup at smc.vnet.net
- Subject: [mg105097] Re: MatchQ, silly question
- From: Albert Retey <awnl at gmx-topmail.de>
- Date: Sat, 21 Nov 2009 03:31:52 -0500 (EST)
- References: <he5v9i$3gh$1@smc.vnet.net>
janos schrieb: > 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? just evaluate this: (_)*(_)^(_) to see that it gives _^(_+1) just as x*x^x would evaluate to x^(x+1), _ or Blank[] is not treated special in this case. To prevent the evaluation of the patterns, use HoldPattern: MatchQ[3 x^2, #] & /@ {3 x_^2, 3 x_^_, _ x_^_, HoldPattern[_ _^_], HoldPattern[_ (_^_)], HoldPattern[_*(_^_)]} works as I think you expect... hth, albert