smallestOccurrence method
Finds the smallest occurrence in the list.
Returns the smallest element in the list based on the Comparable implementation.
Implementation
double? smallestOccurrence() {
// check if the list is empty before calling reduce
if (isEmpty) {
return null;
}
return reduce((double value, double element) => value.compareTo(element) < 0 ? value : element);
}