ver1 = 2 x
verf[x_] := ver1
verf[3]
Result : 2 x
Expected Result : 6
In the above code sample, ver1 can change to expressions (4 x + 3,3 x etc)
What is wrong in the code? How can I achieve my objective?
ver1 = 2 x
verf[x_] := ver1
verf[3]
Result : 2 x
Expected Result : 6
In the above code sample, ver1 can change to expressions (4 x + 3,3 x etc)
What is wrong in the code? How can I achieve my objective?
If you do not want to use set delayed in ver1, this is ver1[x_]:= 2 x, you need to evaluate ver1 when verf is defined:
ver1 = 2 x
verf[x_] := Evaluate[ver1]
verf[3]
=(Set) rather than:=(SetDelayed) and leave outEvaluate, for the same effect. I believed that you were looking for a somewhat different evaluation behavior as described in the marked duplicate; even if you are not you may wish to familiarize yourself with that. – Mr.Wizard Oct 12 '15 at 06:59