MathGroup Archive 1999

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

Search the Archive

Re: Scoping and named patterns


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