average static method

double average(
  1. Iterable<num> values
)

Returns the arithmetic mean of values, or 0 if empty.

Implementation

static double average(Iterable<num> values) {
  if (values.isEmpty) return 0;
  return values.fold<double>(0, (a, b) => a + b) / values.length;
}