Re: local or global variables
- To: mathgroup at smc.vnet.net
- Subject: [mg111011] Re: local or global variables
- From: Bob Hanlon <hanlonr at cox.net>
- Date: Fri, 16 Jul 2010 07:00:03 -0400 (EDT)
Either should work if you use /. rather than \.
Clear[f]
f[x_] := Module[{},
sigma /. {{sigma -> 1}, {sigma -> 2}}]
f[5]
{1,2}
Clear[f]
f[x_] := Module[{sigma},
sigma /. {{sigma -> 1}, {sigma -> 2}}]
f[5]
{1,2}
Bob Hanlon
---- lynette <xiaochu at gmail.com> wrote:
=============
HI:
I have encountered a problem as follow, can anyone help? thanks a
lot.
when sigma is defined as local variable, the function doesn't work
f[x_]:=Module[
{sigma},
sigma \. {{sigma->1},{sigma->2}}
]
when sigma is NOT defined as local variable, the function works
f[x_]:=Module[
{},
sigma \. {{sigma->1},{sigma->2}}
]