average function

double average(
  1. List<int> numbers
)

Sonlar ro'yxatining o‘rtacha qiymatini hisoblash

Implementation

double average(List<int> numbers) {
  if (numbers.isEmpty) {
    throw ArgumentError('Bo\'sh ro\'yxat uchun o\'rtacha hisoblab bo\'lmaydi');
  }
  return numbers.reduce((a, b) => a + b) / numbers.length;
}