Sum value of ns entries.
ns
static double sum(Iterable<num> ns) { if (ns.isEmpty) return 0; var total = 0.0; for (var n in ns) { total += n; } return total; }