Re: [Q] Extracting patterns
- To: mathgroup at smc.vnet.net
- Subject: [mg18688] Re: [mg18607] [Q] Extracting patterns
- From: "Wolf, Hartmut" <hwolf at debis.com>
- Date: Thu, 15 Jul 1999 01:46:04 -0400
- Organization: debis Systemhaus
- References: <199907130501.BAA09554@smc.vnet.net.>
- Sender: owner-wri-mathgroup at wolfram.com
Hello Kevin, Kevin Jaffe schrieb: > > How can I extract the first argument of expressions having the form > Pattern[x, y]? I know how to do something like this in other > situations, e.g.: > > In[1]:= Plus[x, y] /. Plus[a_, b_] -> a > > Out[1]= x > > But this strategy fails when the head of the lhs expression is Pattern: > > In[2]:= Pattern[x, y] /. Pattern[a_, b_] -> a > > Pattern::patsym: First element in pattern Pattern[a_, b_] is not a symbol. > > Out[2]= x:y > > In a last-gasp effort, I also tried: > > In[3]:= Pattern[x, y] /. HoldPattern[Pattern[a_, b_]] -> a > > Pattern::patsym: First element in pattern Pattern[a_, b_] is not a symbol. > > Out[3]= x:y > > to no avail. Is there a way to do this? > In[2]:= Pattern[a,b] /. Verbatim[Pattern][x_,_] :> x Out[2]= a does it, kind regards, hw
- References:
- [Q] Extracting patterns
- From: "Kevin Jaffe" <kj0@mailcity.com>
- [Q] Extracting patterns