mode function

double mode(
  1. Array a
)

Return the mode of all elements of the array. When more than one value has the highest frequency, the first one found in the array is returned; use multimode to get all of them.

Examples

var n = Array([1, 2, 3, 3]);

print(mode(n));

/* output:
3.0
*/

Implementation

double mode(Array a) {
  if (a.isEmpty) {
    throw FormatException('mode of an empty array is undefined');
  }
  return multimode(a).first;
}