org.nield.kotlinstatistics.ComparableStatistics.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of kotlin-statistics Show documentation
Show all versions of kotlin-statistics Show documentation
Statistical and analytical extensions for Kotlin
package org.nield.kotlinstatistics
inline fun ,K> Sequence.minBy(crossinline keySelector: (T) -> K, crossinline valueSelector: (T) -> R) =
groupApply(keySelector, valueSelector) { it.min() }
inline fun ,K> Iterable.minBy(crossinline keySelector: (T) -> K, crossinline valueSelector: (T) -> R) =
asSequence().minBy(keySelector, valueSelector)
fun > Sequence>.minBy() =
groupApply({it.first}, {it.second}) { it.min() }
fun > Iterable>.minBy() = asSequence().minBy()
inline fun ,K> Sequence.maxBy(crossinline keySelector: (T) -> K, crossinline valueSelector: (T) -> R) =
groupApply(keySelector, valueSelector) { it.max() }
inline fun ,K> Iterable.maxBy(crossinline keySelector: (T) -> K, crossinline valueSelector: (T) -> R) =
asSequence().maxBy(keySelector, valueSelector)
fun ,K> Sequence>.maxBy() =
groupApply({it.first}, {it.second}) { it.max() }
fun ,K> Iterable>.maxBy() = asSequence().maxBy()