ifThen
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.*
fun main(args: Array<String>) {
//sampleStart
val result =
listOf(1,2,3).ifThen(listOf("empty")) { i ->
listOf("$i, ${i + 1}")
}
//sampleEnd
println(result)
}
Content copied to clipboard
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())
}
Content copied to clipboard