Writing a method to write a method?
I am curious if there is a way to use a string that's syntactically the same as the body of a method to define a method by the program. I wanted to make a program where the user is prompted to type in a function (3x^2+(2x-3)^.5 for example) and then have the program create a class or method to call in order to evaluate the function at different x-values. this is easy if one knows the function ahead of time--just write it inside a method in proper syntax and have the method return the answer--but I don't know how or if I can (after "translating" the above into something like 3*Math.pow(x,2)+Math.pow(2*x-3,.5)) code the program to create a new method or a class with a method that returns the function evaluated at a given x. Any pointers or directions to go with this would be greatly appreciated :D