MathGroup Archive 2005

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

Search the Archive

Re: named pattern variable scoped as global, should be local

  • To: mathgroup at smc.vnet.net
  • Subject: [mg56798] Re: named pattern variable scoped as global, should be local
  • From: Lee Newman <leenewm at umich.edu>
  • Date: Fri, 6 May 2005 03:00:15 -0400 (EDT)
  • References: <d59kg5$6ch$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Thanks everyone for the helpful comments...

-Lee

leenewman at gmail.com wrote:
> When using a named pattern variable within a module, it should be
> scoped locally within the pattern.  However, this does not seem to work
> as advertised.  For example, shouldn't the pattern variable x in the
> statements below be local to the pattern?  Does anyone know whether
> this is a bug, or whether I am just missing something about the usage
> of variables in patterns/condition constructs?
> 
> (* this returns 14! *)
> x = 7;
> Module[{x},{1, 2, 3} /. x_ -> 2x];
> 
> (* this returns {2,4,6}, assuming q is not globally defined. *)
> Remove[q];
> Module[{q},{1, 2, 3} /. q_ -> 2q];
> 
> 
> Lee
> 


  • Prev by Date: Re: nesting while function
  • Next by Date: Re: ZTarnsform[Sin[4 n],n,z] OK, but ZTransform[Sin[5 n],n,z,] hangs?
  • Previous by thread: Re: named pattern variable scoped as global, should be local
  • Next by thread: Variant of inner Product ...