Is there a way to create a function as below?
I need to calculate the area of triangle, and I don’t remember the right formula to calculate this and there is no internet or other sources of some information to me. What I do remember is that arguments for such function are some side b and height h. So I want to create some function which would look like this:
public static void calculate(String forgottenFunc, int... params) {/*implementation*/};
I thought of implementing based on JavaScript eval function from Java, withough using RegExp. I’ve got stuck on converting string (forgottenFunc) to some real function that would use given parametrs to calculate what I need. Or any alternatives on Python’s eval or some other feature.
Thanks
Try Jep, a free Java math parser.