I am able to do this:
def largestAt(fun: (Int) => Int, inputs: Seq[Int]):Int = {
inputs.reduceLeft(math.max(_,_))
}
But, when I am trying to do this:
def largestAt(fun: (Int) => Int, inputs: Seq[Int]):Int = {
inputs.reduceLeft(math.max(fun(_),fun(_)))
}
I am getting below mentioned compilation error:
overloaded method value max with alternatives:
[error] (x: Double,y: Double)Double <and>
[error] (x: Float,y: Float)Float <and>
[error] (x: Long,y: Long)Long <and>
[error] (x: Int,y: Int)Int
[error] cannot be applied to (Int => Int, Int => Int)
[error] inputs.reduceLeft(math.max(fun(_),fun(_)))
I just want to pass the result of the fun
to math.max
call. How can I achieve this.
Thanks in advance...