🚗🏍️ Welcome to Motoshare!

Turning Idle Vehicles into Shared Rides & New Earnings.
Why let your bike or car sit idle when it can earn for you and move someone else forward?

From Idle to Income. From Parked to Purpose.
Earn by Sharing, Ride by Renting.
Where Owners Earn, Riders Move.
Owners Earn. Riders Move. Motoshare Connects.

With Motoshare, every parked vehicle finds a purpose. Partners earn. Renters ride. Everyone wins.

Start Your Journey with Motoshare

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
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x