Answer the question
In order to leave comments, you need to log in
How to convert a mathematical function of type String to a regular function in Java?
There is a mathematical function like String function = "12*x^2-132*x^3" how can such a function be converted so that it can be calculated
Answer the question
In order to leave comments, you need to log in
to make lexical analysis
as a whole they teach at school
more thoroughly with theory they teach at the university in the course of the basics of programming languages, where they learn to write their own programming languages and parse the source code of the program.
Ha, the easiest way is to pick up some kind of interpreted language. For example run this in jython, groovy or even javascript!
In other words. Link your application with your favorite interpreter library and call
BSFManager manager = new BSFManager();
Vector<String> ignoreParamNames = null;
Vector<Integer> args = new Vector<Integer>();
args.add(2);
args.add(5);
args.add(1);
Integer actual = (Integer) manager.apply("groovy", "applyTest", 0, 0,
"def summer = { a, b, c -> a * 100 + b * 10 + c }", ignoreParamNames, args);
assertEquals(251, actual.intValue());
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question