Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1999
*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 1999

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

Search the Archive

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



  • Prev by Date: Re: importing multiple files
  • Next by Date: Re: Solving difficult integral
  • Previous by thread: [Q] Extracting patterns
  • Next by thread: RE: [Q] Extracting patterns