MathGroup Archive 2003

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Pattern matches only when named


Ken Morgan <kemorgan at vt.edu> wrote in news:bm2ugv$6so$1 at smc.vnet.net:

> 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
> 
> 

Hi Ken,

In your second example the blank stands for an idendical expression. So 
this pattern matches only when both expressions left and right from the 
plus are the same. Try f+f/._+_->h and look what happens.

You're welcome ;-)

Regards

Oliver Friedrich


  • Prev by Date: What Happens to Garbage in Mathematica?
  • Next by Date: RE: Pattern matches only when named
  • Previous by thread: Re: Pattern matches only when named
  • Next by thread: RE: Pattern matches only when named