|
[Date Index]
[Thread Index]
[Author Index]
Re: Question on pattern matching
- To: mathgroup at smc.vnet.net
- Subject: [mg47807] Re: Question on pattern matching
- From: Bill Rowe <readnewsciv at earthlink.net>
- Date: Tue, 27 Apr 2004 04:47:47 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
On 4/26/04 at 2:40 AM, rgreen at mail.ru (Roman Green) wrote:
>In the following Mathematica's output In[1]:= SetAttributes[k,
>Orderless]
>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,
k[a,b,b]/._k->0
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
|