f[x2_] = ToExpression[StringTake[ToString[x2], -1]] x2;
f[a3]
(*Out: 2 a3*)
I expected the output to be 3 a3, but apparently x2 isn't evaluated in ToString.
How would one construct a function that gives the expected result?
I expected the output to be How would one construct a function that gives the expected result? |
|||
|
You have to use So this gives the correct result:
Have a look at this tutorial on |
||||
|
|
SetDelayed[]instead ofSet[]. – 0x4A4D♦ Oct 10 '12 at 13:29