MathGroup Archive 1995

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

Search the Archive

Re: Equating a variable and its value


jans at matematik.su.se (Jan Snellman) wrote:
>
> 
> Hello folks.
> 
> Study this codelet:
> 
> m=3; mult=Times[#,m]&; Clear[m]; mult[10]
> 
> To my dismay, I get 10 m, not 30.
> How can i convince Mathematica that only pedants make the distinction
> between a variable and its value?
> 
> Regards,
> Jan Snellman	jans at matematik.su.se
> 

In the constuction Times[#,m]& parameter m is not evaluated until 
the time of application of the function because of the non-standard 
evaluation rule of "Function" (see the Book, p. 279).

One possibility to overcome the problem is to write

mult = Function[x,x #]& [m]

Now m gets evaluated at the time of definition by the standard
evaluation procedure.


-- Jorma Virtamo


============================================================     
Jorma Virtamo
VTT Information Technology / Telecommunications
P.O. Box 1202,  FIN-02044 VTT,  Finland
phone: +358 0 456 5612          fax: +358 0 455 0115
email: jorma.virtamo at vtt.fi     web: http://www.vtt.fi/tte/
============================================================



  • Prev by Date: Re: Why can't I solve this SIMPLE problem?
  • Next by Date: INTERACTIVE USE OF MATHEMATICA
  • Previous by thread: Re: Why can't I solve this SIMPLE problem?
  • Next by thread: Re: Equating a variable and its value