You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We are getting Expressions dynamically and we have no idea how many of arguments there will be.So how can we achieve this.Can somebody guide us.Thanks in advance.
Ex :- Expression e = new ExpressionBuilder("sum(1,avg(1,2,3))")
.functions(variableArgsFunctions)
.build();
"sum(1,avg(1,2,3))" expression we will get dynamically.In some cases it may be sum(1,avg(1,2,3,4)).
How can we achieve this.
The text was updated successfully, but these errors were encountered:
Go to -> net.objecthunter.exp4j.Expression.evaluate() --> replace or modify as below (removing check for number of arugment...Perfect way is to add one function without num argument ) ..
....
} else if (t.getType() == Token.TOKEN_FUNCTION) {
FunctionToken func = (FunctionToken) t;
final int numArguments = func.getFunction().getNumArguments();
// if (output.size() < numArguments) {
// throw new IllegalArgumentException("Invalid number of arguments available for '" + func.getFunction().getName() + "' function");
// }
/* collect the arguments from the stack */
double[] args = new double[output.size()];
for (int j = numArguments - 1; j >= 0; j--) {
args[j] = output.pop();
}
output.push(func.getFunction().apply(args));
}
...
Please let me know , if you have any issue on this..
We are getting Expressions dynamically and we have no idea how many of arguments there will be.So how can we achieve this.Can somebody guide us.Thanks in advance.
Ex :- Expression e = new ExpressionBuilder("sum(1,avg(1,2,3))")
.functions(variableArgsFunctions)
.build();
"sum(1,avg(1,2,3))" expression we will get dynamically.In some cases it may be sum(1,avg(1,2,3,4)).
How can we achieve this.
The text was updated successfully, but these errors were encountered: