Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2010

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

Search the Archive

Re: local or global variables

  • To: mathgroup at smc.vnet.net
  • Subject: [mg111009] Re: local or global variables
  • From: Patrick Scheibe <pscheibe at trm.uni-leipzig.de>
  • Date: Fri, 16 Jul 2010 06:59:41 -0400 (EDT)

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}}
> 	]
> 



  • Prev by Date: Re: local or global variables
  • Next by Date: Re: Generate #s
  • Previous by thread: Re: local or global variables
  • Next by thread: MathLink error