How to avoid evaluation into the global space when the expression is not know in advance

So: either they can write the functions as

(x,y) -> x*y

and then use eval on those (that is fine for that purpose). Or, if you really only can expect the user to write

x*y

You need to parse that string to understand which are the variables (are they very limited? is it just checking if x, y and z are present?), and turn that into a string as:

(x,y) -> x*y

But how general you want the input to be will define how complicated this parsing will be.

1 Like