maxval method

T maxval(
  1. int start,
  2. int end
)

Implementation

T maxval(int start, int end) {
  switch (T) {
    case const (double):
    case const (int):
      var value = this[start] as num;
      for (var i = start + 1; i <= end; i++) {
        if (value < (this[i] as num)) value = this[i] as num;
      }
      return value as T;

    case const (Complex):
      var value = this[start] as Complex;
      for (var i = start + 1; i <= end; i++) {
        if (value < (this[i] as Complex)) value = this[i] as Complex;
      }
      return value as T;

    case const (bool):
      for (var i = start; i <= end; i++) {
        if (this[start] as bool) return true as T;
      }
      return false as T;
    default:
      throw UnimplementedError();
  }
}