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: Scoping and named patterns

  • To: mathgroup at smc.vnet.net
  • Subject: [mg18153] Re: Scoping and named patterns
  • From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
  • Date: Sat, 19 Jun 1999 23:54:23 -0400
  • Organization: Universitaet Leipzig
  • References: <7kcjrn$lql@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Hi,

Rule[] evaluate it's arguments. RuleDelayed[] wirks as expected:

In[9]:=
n = 2; x = 3;        
f[a^b] /. f[x : _^n_] :> p[x, n]//InputForm

Out[9]//InputForm=
p[a^b, b]



Hope that helps
  Jens


Dr Dan wrote:
> 
> I am having trouble with name conflicts between global symbols and
> named patterns.

... SNIP SNAPP ...

> But if the symbols used as pattern names have values:
> 
> In[3]:= n = 2; x = 3;
>         f[a^b] /. f[x : _^n_] -> p[x, n]
> Out[3]= p[3, 2]
> 
> My usual favorite scoping structure, Module, doesn't help:
> 
> In[4]:= Module[{x, n}, f[a^b] /. f[x : _^n_] -> p[x, n]]
> Out[4]= p[3, 2]
> 
> This looks like a bug to me.  If I use a symbol in a local context I
> expect the local symbol and never the global.  
SNIPP SNAPP
> Any comments, or a better workaround than Block?
> 
> Sent via Deja.com http://www.deja.com/
> Share what you know. Learn what you don't.


  • Prev by Date: Re: Dealing with submatrices
  • Next by Date: Re: Pipes within Mathematica?
  • Previous by thread: Re: Scoping and named patterns
  • Next by thread: Re: Scoping and named patterns