1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
|
Parser p = new Parser("123+546+345");
System.out.println(p.calc(new HashMap<String, Double>())); //1014.0
Parser p2 = new Parser("x+3*y");
HashMap<String, Double> input = new HashMap<>();
input.put("x", 2.0);
input.put("y", 3.0);
System.out.println(p2.calc(input)); //11.0
Parser p3 = new Parser("x^3*sin(x)");
System.out.println(p3.derive("x")); //3*x^2*sin(x)+x^3*cos(x) |