MathFunction getFunction(String name)

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.

Source

MathFunction getFunction(String name) {
  var 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 new StateError('Function not bound: $name');
  }
}