evaluate method
Evaluates this expression according to given type and context.
Implementation
@override
dynamic evaluate(EvaluationType type, ContextModel context) {
final dynamic argEval = arg.evaluate(type, context);
if (argEval < 0) {
throw ArgumentError.value(
argEval, 'Factorial', 'Negative values not supported.');
} else if (argEval == double.infinity) {
throw ArgumentError.value(
argEval, 'Factorial', 'Infinity not supported.');
}
if (type == EvaluationType.REAL) {
dynamic product = 1.0;
for (int i = 1; i <= argEval.round(); i++) {
product *= i;
}
return product;
}
throw UnimplementedError('Can not evaluate $name on $type yet.');
}