MathGroup Archive 1999

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

Search the Archive

Re: [Q] Extracting patterns

  • To: mathgroup at smc.vnet.net
  • Subject: [mg18667] Re: [mg18607] [Q] Extracting patterns
  • From: "Andrzej Kozlowski" <andrzej at tuins.ac.jp>
  • Date: Thu, 15 Jul 1999 01:45:52 -0400
  • Sender: owner-wri-mathgroup at wolfram.com

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