MathGroup Archive 2004

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

Search the Archive

Re: Question on pattern matching

  • To: mathgroup at
  • Subject: [mg47807] Re: Question on pattern matching
  • From: Bill Rowe <readnewsciv at>
  • Date: Tue, 27 Apr 2004 04:47:47 -0400 (EDT)
  • Sender: owner-wri-mathgroup at

On 4/26/04 at 2:40 AM, rgreen at (Roman Green) wrote:

>In the following Mathematica's output In[1]:= SetAttributes[k,

>In[2]:= k[a, b, b] /. k[x_, x_, y_] -> 0 
>Out[2]= 0
>In[3]:= k[a, b, b] /. k_[x_, x_, y_] -> 0 
>Out[3]= k[a, b, b]

>I can't understand why Mathematica can find match when applying
>pattern k[x_, x_, y_], but is unable with more general pattern
>k_[x_, x_, y_].

The pattern k_ matches an expression named k with any head

k[a, b, b] is an expression with head k and no name. The two things don't match which is why you get the output you got.

The pattern _k is any expression with head k. So,


will result in what you were expecting
To reply via email subtract one hundred and four

  • Prev by Date: Re: Parametric Plot.
  • Next by Date: Re: Question on pattern matching
  • Previous by thread: Question on pattern matching
  • Next by thread: Re: Re: Question on pattern matching