I would like to refactor this piece of Scala code in functional style:
var k = -1
for (i <- 0 until array.length)
if ((i < array.length - 1) && array(i) < array(i + 1))
k = i
Array in Scala has indexWhere, which can be used for something like val index = array.indexWhere(c => c == 'a'). I'm looking for something similar, which would take into account two sequential elements of array.