MathGroup Archive 1999

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

Search the Archive

[Q] Extracting patterns



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?

Thanks,

kj0 at mailcity.com



Get your FREE Email at http://mailcity.lycos.com
Get your PERSONALIZED START PAGE at http://my.lycos.com


  • Prev by Date: Re: col-vector * row-vector = matrix, how ?
  • Next by Date: RE: Re: "At long last, Sir, have you no shame?"
  • Previous by thread: Concurrent Curve Fitting... II
  • Next by thread: Re: [Q] Extracting patterns