package org.matheclipse.core.reflection.system;
import org.matheclipse.core.eval.exception.Validate;
import org.matheclipse.core.eval.interfaces.AbstractFunctionEvaluator;
import org.matheclipse.core.interfaces.IAST;
import org.matheclipse.core.interfaces.IExpr;
import org.matheclipse.core.interfaces.ISymbol;
/**
* Get the default value for a symbol (i.e. 1 is the default value for Times, 0 is the
* default value for Plus).
*/
public class Default extends AbstractFunctionEvaluator {
public Default() {
}
@Override
public IExpr evaluate(final IAST ast) {
Validate.checkRange(ast, 2, 4);
ISymbol symbol = Validate.checkSymbolType(ast, 1);
if (ast.size() > 2) {
int pos = Validate.checkIntType(ast, 2);
return symbol.getDefaultValue(pos);
} else {
return symbol.getDefaultValue();
}
}
}
Ads help maintain this website.