median

inline fun <T> Array<T>.median(): Pair<T, T?>

Computes the median of the value Array.

Notice -> In pair list of values, the median is the two middle value.

Example:

arrayOf(1 , 5 , 3 , 9 , 0 , 4).median() // (3, 4)
arrayOf(1 , 5 , 3 , 0 , 4).median() // (3 , null)

Since

1.1.0

Throws

IllegalArgumentException

if the Array is empty.


inline fun <T> Iterable<T>.median(): Pair<T, T?>

Computes the median of the value Iterable.

Notice -> In pair list of values, the median is the two middle value.

Example:

listOf(1 , 5 , 3 , 9 , 0 , 4).median() // (3, 4)
listOf(1 , 5 , 3 , 0 , 4).median() // (3 , null)

Since

1.1.0

Throws

IllegalArgumentException

if the Iterable is empty.