This is Kotlin's equivalent of a function taken from Scala MOOC on Coursera. It returns a function that applies the given mapper (f) in the range (a..b)
fun sum(f: (Int) -> Int): (Int, Int) -> Int {
fun sumF(a: Int, b: Int): Int =
if (a > b) 0
else f(a) + sumF(a + 1, b)
return sumF
}
But IntelliJ shows these errors. How can I return the function here.
source
share