MathGroup Archive 1999

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

Search the Archive

Re: [Q] Extracting patterns


You were nearly there. The correct function is not HoldPattern but Verbatim

In[5]:=
Pattern[x, y] /. Verbatim[Pattern[a_, b_] ] -> a
Out[5]=
x:y

In[6]:=
FullForm[%]
Out[6]//FullForm=
Pattern[x, y]
--
Andrzej Kozlowski
Toyama International University
JAPAN
http://sigma.tuins.ac.jp
http://eri2.tuins.ac.jp


----------
>From: "Kevin Jaffe" <kj0 at mailcity.com>
To: mathgroup at smc.vnet.net
>To: mathgroup at smc.vnet.net
>Subject: [mg18667] [mg18607] [Q] Extracting patterns
>Date: Tue, Jul 13, 1999, 2:01 PM
>

>
>
> 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: [Q] Extracting patterns
  • Next by Date: Re: Solving difficult integral
  • Previous by thread: RE: [Q] Extracting patterns
  • Next by thread: Re: [Q] Extracting patterns