fun maxIndex(doubles: DoubleArray): Int { var maximum = 0.0 var maxIndex = 0 for (i in doubles.indices) { if (i == 0 || doubles[i] > maximum) { maxIndex = I maximum = doubles[i] } } return maxIndex }
Returns index of maximum element in a given array of doubles . First maximum is returned .