From: lynette on
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}}
]

From: Patrick Scheibe on
Hi,

the ReplaceAll operator uses a slash not a backslash!
Here it your corrected code gives

In[24]:= f[x_] :=
Module[{sigma}, sigma /. {{sigma -> 1}, {sigma -> 2}}]
f[x]

Out[25]= {1, 2}

Cheers
Patrick


On Fri, 2010-07-16 at 05:16 -0400, lynette 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}}
> ]
>


From: Bob Hanlon on

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(a)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}}
]