Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
implicit def clipMinArrayWrapper[A <% Ordered[A]](x: Array[A]) = new {
private def smaller[B <% Ordered[B]](p: B, q: B) : B = {
if (p < q) return(p) else return(q)
}
def min() : A = {
min((p) => p)
}
def min[B <% Ordered[B]](f: A => B) : B = {
return x.slice(1,x.length).foldLeft(f(x(0)))((p,q) => smaller(p, f(q)))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.