average<T> static method
Returns the arithmetic mean of list, or 0 when empty.
Implementation
static double average<T>(Iterable<T> list, {num Function(T)? by}) {
if (list.isEmpty) return 0;
var total = 0.0;
var count = 0;
for (final v in list) {
total += by != null ? by(v) : (v as num);
count++;
}
return total / count;
}