getFunction method
Returns the function for the given function name.
Performs recursive lookup through parentScope
.
Throws a StateError, if function is still unbound at the root scope.
Implementation
MathFunction getFunction(String name) {
final Iterable<MathFunction> candidates =
functions.where((mathFunction) => mathFunction.name == name);
if (candidates.isNotEmpty) {
// just grab first - should not contain doubles.
return candidates.first;
} else if (parentScope != null) {
return parentScope!.getFunction(name);
} else {
throw StateError('Function not bound: $name');
}
}