Re: Pattern matching

*To*: mathgroup at smc.vnet.net*Subject*: [mg116587] Re: Pattern matching*From*: Leonid Shifrin <lshifr at gmail.com>*Date*: Mon, 21 Feb 2011 04:19:47 -0500 (EST)*References*: <ijo54e$lf0$1@smc.vnet.net>

It is not an alternative in a strict sense. Look at the FullForm: In[108]:= x:_:0//FullForm Out[108]//FullForm= Optional[Pattern[x,Blank[]],0] In[110]:= x_.//FullForm Out[110]//FullForm= Optional[Pattern[x,Blank[]]] In the second case, you are relying on the default values for the head surrounding the pattern (Plus in the case of the original problem). In the first case, you specify the default value yourself. In other words, in the first case the default belongs to the pattern, while in the second - to the surrounding function. And this form is surely documented, have a look at Optional, the second paragraph under More Information section. Regards, Leonid On Sun, Feb 20, 2011 at 5:16 AM, Alexey <lehin.p at gmail.com> wrote: > On 19 =D1=84=D0=B5=D0=B2, 15:13, Leonid Shifrin <lshifr at gmail.com> wrote: > > Could do this: > > > > In[1]:= f[u] /. f[u + x : _ : 0] -> x > > > > Out[1]= 0 > > > > Regards, > > Leonid > > Is the form "x : _ : 0" a non-standard alternative to "x_."? Btw I > cannot find where this form is documented.