I would like to define a function as follows:
double f ( double x ){
return what_certain_string_says_to_do_on_x;
}
That behaves as the intuition suggests: if such string is equal to "sin(x)", the resulting function will be the usual sine, and so on. For sake of simplicity, assume to always have a variable named "certain_string" that always contains well-defined instructions.
Does anyone have some suggestion?
The only "solution" I see is to write a simple script that rewrite the C source code by replacing the line "return what_certain_string_says_to_do_on_x;" with the explicit characters contained in the string, and then recompile. It works, but I would like to obtain something simpler and quicker.
Thanks a lot in advance for any kind of help.