Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
argmax in Scala
implicit class ArgmaxColl[A, CC[X] <: Seq[X]](val coll: CC[A]) extends AnyVal {
def argmax(implicit o:Ordering[A]): Int = coll.indices.maxBy(coll)
}
val as = scala.util.Random.shuffle(1 to 10)
as.argmax
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment