Re: Pattern matches only when named
- To: mathgroup at smc.vnet.net
- Subject: [mg43877] Re: [mg43873] Pattern matches only when named
- From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
- Date: Fri, 10 Oct 2003 03:05:46 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
This works: In[3]:= f+g/.HoldPattern[_+_]->h Out[3]= h In your second case you need HoldPattern, otherwise your pattern evaluates to 2 _ (2 Blank[]) which does not match anything. On Thursday, October 9, 2003, at 02:55 PM, Ken Morgan wrote: > Just a curiosity: > > In[1]:= f + g /. u_ + _ -> h > Out[1]:= h > > but > > In[2]:= f + g /. _ + _ -> h > Out[2]:= f + g > > Why does the pattern match only when one of the Blanks has a name? > > > Thanks, > Ken > > > Andrzej Kozlowski Yokohama, Japan http://www.mimuw.edu.pl/~akoz/ http://platon.c.u-tokyo.ac.jp/andrzej/