dynamic evaluate(EvaluationType type, ContextModel context)

Evaluates this expression according to given type and context.

Source

evaluate(EvaluationType type, ContextModel context) {
  var argEval = arg.evaluate(type, context);

  if (type == EvaluationType.REAL) {
    return Math.sqrt(argEval);
  }

  if (type == EvaluationType.VECTOR) {
    //TODO apply function to all vector elements
  }

  if (type == EvaluationType.INTERVAL) {
    // Piecewiese sqrting.
    return new Interval(Math.sqrt(argEval.min), Math.sqrt(argEval.max));
  }

  throw new UnimplementedError('Can not evaluate sqrt on ${type} yet.');
}