Re: basic pattern matching
- To: mathgroup at smc.vnet.net
- Subject: [mg114349] Re: basic pattern matching
- From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
- Date: Thu, 2 Dec 2010 05:36:50 -0500 (EST)
On 30 Nov 2010, at 12:22, Peter Pein wrote: > > In[3]:== Cases[x,a_.*x:>a] > Out[3]== {} > should have been {1} shouldn't it? If the pattern matches (see > Out[2]) then with a_. ==== 1. (Bug or feature?) > > In[4]:== Cases[y+x,a_.*x:>a] > Out[4]== {1} > is OK. > > Any enlightenment is highly welcome, > thanks in advance, Peter > I think this is just a matter of the level at which Cases is applied. Note that: Cases[x, a_.*x :> a, {0}] {1} Andrzej Kozlowski