arrow-core-data / arrow.core / AndThen / compose
infix fun <C> compose(g: (C) -> A):
AndThen
<C, B>
Compose a function to be invoked before the current function is invoked.
import arrow.core.AndThen
fun main(args: Array<String>) {
//sampleStart
val f = (0..10000).fold(AndThen { i: Int -> i + 1 }) { acc, _ ->
acc.compose { it + 1 }
}
val result = f(0)
//sampleEnd
println("result = $result")
}
g
- function to invoke before invoking this function with the result.
Return a composed AndThen function that first applies g to its input, and then applies this function to the result.
Do you like Arrow?
✖