Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2003
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2003

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

Search the Archive

Re: Pattern matches only when named

  • To: mathgroup at smc.vnet.net
  • Subject: [mg43908] Re: Pattern matches only when named
  • From: Oliver Friedrich <oliver.friedrich at tzm.de>
  • Date: Sat, 11 Oct 2003 01:33:28 -0400 (EDT)
  • Organization: TZ Mikroelektronik
  • References: <bm2ugv$6so$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

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