MathGroup Archive 1999

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

Search the Archive

Evaluate/Module


Hi,

I'm having some trouble with Evaluate and i cannot find this in the
documentation.
Does anybody know what and esp. why the following is happening?

		In1:= tmp = x^2 +1; 

		In2:= Module[{x=4},tmp=tmp-1;Print[tmp]; Evaluate[tmp]]

		x^2
		x^2 + 1

In the above Evaluate[tmp] somehow takes the latest value of tmp and not
the current one after the "tmp=tmp-1". Why?

Changing "Evaluate[tmp] to "l=Evaluate[tmp]" does give the right answer
(in this case x^2) immediately. Does this assignment force Evaluate to
Evaluate tmp before ending the Module. Does someone know more about
Evaluate and Modelule?

		lM[x0_]:= Module[{lonediff,lMdiff,ldead,lone,search},
		lonediff= 1 + lone/2 - x0/lone - 2 / (1 + Exp[2*ldead - 2*lone]);
		lMdiff = (2*(x0/(1+x0) )*E^(-ldead+ lone))/(E^(2*lone-2*ldead)+1)-
0.1;	
		search=FindRoot[{lMdiff==0, lonediff==0 },{ldead,x0+1} ,{lone,x0}];    
		Evaluate[ldead /. search]
		];		

		lM[6]	

		ReplaceAll::"reps": 
	  	  {search$77} is neither a list of replacement rules nor a valid
		dispatch table, and so cannot be used for replacing."

		5.44865

In this module Evaluate somehow is looking for an global "search"
variable.
Why does it not just evaluate this local "search"?

Thanks,

Bernd


  • Prev by Date: Syntax error in notebook saved as package
  • Next by Date: How can I plot for array variable?
  • Previous by thread: RE: Syntax error in notebook saved as package
  • Next by thread: Re: Evaluate/Module