 
 
 
 
 
 
Summary: equating a variable with its value
- To: mathgroup at christensen.cybernetics.net
- Subject: [mg1264] Summary: equating a variable with its value
- From: jans at matematik.su.se (Jan Snellman)
- Date: Mon, 29 May 1995 03:48:53 -0400
- Organization: Department of Mathematics, Stockholm University
Hello again, folks!
A few days ago, I presented my problems with the pure function
multiplication by m :
>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?
The response has been overwhelming! Thank you all!
I feel it is my duty to summarize the many and instructing answers I
received. 
1. mult = Function[x,x #]& [m]
2. mult = With[{m = m}, Times[#, m]& ]
3. mult=Module[{n=m},Function[{x},x*n]]
4. mult=Evaluate[Times[#,m]]&
5. ClearAttributes[Function,{Protected,HoldAll}]; mult=Times[#,m]&
6. SetMult[v_] := mult=Times[v,#]&; SetMult[m]
7. mult = Times[#, m]& /. Literal[m] -> m
--
Jan Snellman         : "Whenever you find that you are on the side of the 
jans at matematik.su.se : majority, it is time to reform."  M T

