arrow-core-data / arrow.core / kotlin.sequences.Sequence / ifThen
fun <A, B>
Sequence
<A>.ifThen(fb:
Sequence
<B>, ffa: (A) ->
Sequence
<B>):
Sequence
<B>
Logical conditional. The equivalent of Prolog’s soft-cut. If its first argument succeeds at all, then the results will be fed into the success branch. Otherwise, the failure branch is taken.
import arrow.core.ifThen
fun main(args: Array<String>) {
//sampleStart
val result =
sequenceOf(1,2,3).ifThen(sequenceOf("empty")) { i ->
sequenceOf("$i, ${i + 1}")
}
//sampleEnd
println(result.toList())
}
Do you like Arrow?
✖