public class FoldList extends AbstractCoreFunctionEvaluator
Constructor and Description |
---|
FoldList() |
Modifier and Type | Method and Description |
---|---|
IExpr |
evaluate(IAST ast,
EvalEngine engine)
Symbolic evaluation of a function.
|
static IExpr |
evaluateNestList(IAST ast,
IAST resultList,
EvalEngine engine) |
static IAST |
foldLeft(IExpr expr,
IAST list,
int start,
int end,
java.util.function.BiFunction<IExpr,IExpr,? extends IExpr> binaryFunction,
IAST resultCollection)
Fold the list from
start index including to end
index excluding into the resultCollection . |
void |
setUp(ISymbol symbol)
Evaluate built-in rules and define Attributes for a function.
|
numericEval
public IExpr evaluate(IAST ast, EvalEngine engine)
AbstractCoreFunctionEvaluator
ast.get(0)
(or alternatively ast.head()
) contains the
head (i.e. the function symbol) of this abstract syntax tree (AST). ast.arg1()
to ast.get(n)
the ast
contains the first to n-th argument of the
function (alternatively you get the first to fifth argument with the methods arg1()
, arg2()
,...
arg5()
).Validate
class to check the number or types of arguments in the evaluate
method.null
value without throwing an exception!evaluate
in interface IFunctionEvaluator
evaluate
in class AbstractCoreFunctionEvaluator
ast
- the abstract syntax tree (AST) which should be evaluatedengine
- the users current evaluation enginenull
, if evaluation isn't possibleValidate
,
IExpr.head()
,
IAST.arg1()
,
IAST.arg2()
,
IAST.arg3()
public static IExpr evaluateNestList(IAST ast, IAST resultList, EvalEngine engine)
public void setUp(ISymbol symbol)
AbstractCoreFunctionEvaluator
setUp
in interface IEvaluator
setUp
in class AbstractCoreFunctionEvaluator
symbol
- the symbol which should be set uppublic static IAST foldLeft(IExpr expr, IAST list, int start, int end, java.util.function.BiFunction<IExpr,IExpr,? extends IExpr> binaryFunction, IAST resultCollection)
start
index including to end
index excluding into the resultCollection
. If the
binaryFunction returns null
, the left element will be
added to the result list, otherwise the result will be folded
again with the next element in the list.list
- start
- end
- binaryFunction
- resultCollection
-