Re: basic pattern matching
- To: mathgroup at smc.vnet.net
- Subject: [mg114412] Re: basic pattern matching
- From: Peter Pein <petsie at dordos.net>
- Date: Fri, 3 Dec 2010 05:23:13 -0500 (EST)
- References: <id7sv0$l06$1@smc.vnet.net>
Thank you all!
I felt a "clap" on my forehead -- must have been my own flat
hand ;-)
Peter
Am Thu, 2 Dec 2010 10:38:24 +0000 (UTC)
schrieb Andrzej Kozlowski <akoz at mimuw.edu.pl>:
>
> 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
>
>