Upgrade & Secure Your Future with DevOps, SRE, DevSecOps, MLOps!

We spend hours on Instagram and YouTube and waste money on coffee and fast food, but won’t spend 30 minutes a day learning skills to boost our careers.
Master in DevOps, SRE, DevSecOps & MLOps!

Learn from Guru Rajesh Kumar and double your salary in just one year.



Get Started Now!

Dart – Find min, max in a List using dart:math and list reduce()

Uncategorized

Let we have a list of integers

final // is Keyword
final numbers = [4, 2, 8, 3, 1, 5, 7, 9];

find min value, max value in this list using ‘dart:math’ library

import 'dart:math';

int findMinimum(List<int> numbers) {
  return numbers.reduce(min);
}

int findMaximum(List<int> numbers) {
  return numbers.reduce(max);
}

Let’s do the test

Output

MINIMUM: 1
MAXIMUM: 9

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x