Let's say I store an expression in a variable:
exprsn := x^2 + 3
Now, I want to turn it into a function, so I do:
f(x) := exprsn
But then, if I type "f(7)", I get "exprsn" instead of "7^2 + 3". How to fix this?
I did "f(x) := eval(exprsn)", and it (seems to?) work.
My questions:
1. Is this the correct way to solve the problem?
2. Why is there a problem in the first place? I.e, why isn't the 'exprsn' varible resolved in "f(x) := exprsn"?
2. If I type "f" it says "x -> eval(exprsn)", and I would have prefered it to say "x -> x^2 + 3".
"Unholding" variables
Modérateur : xcasadmin
Re: "Unholding" variables
You should use unapply to do that.
exprsn := x^2 + 3;
f:=unapply(exprsn,x)
exprsn := x^2 + 3;
f:=unapply(exprsn,x)