How to convert a string into a function in JS?

I want to write a function that is then called by the program 1000ds times to make your own mesh world for users to roam in.

eval() is great, i have used it to print maths and texts, and also to call a function.

for my game though, i dont need to actively call an action, i need users to write abit of maths, that will then become a function, that the program will then call many times.

i.e. .JS is function:

function equation(x:float,y:float,z:float):float
{
   return (x*x+y*y+z*z-1);
}

users can replace / rewrite above function so that:

GUI Text:

function equation(x:float,y:float,z:float):float
{
   return (Mathf.Sin (x)*Mathf.Cos (y)+z*z-5);
}

is it possible?
it’s abit confusing arg 8-/

If you use Reflection you can get an actual function from its name; depending on how much you trust your user you may need to be creative and, for instance, only allow methods from Mathf to be called.

See the answer here Calling non applied scripts - Questions & Answers - Unity Discussions for how to use a string to find and call a function.

Maybe this article can help you - at first sight, it shows how to compile some code at runtime, and how to use the resulting assembly.