com.natpryce.iterables.kt Maven / Gradle / Ivy
package com.natpryce
fun Iterable>.allValues(): Result, E> =
Ok(map { r -> r.onError { return it } })
fun Iterable>.anyValues(): List =
filterIsInstance>().map { it.value }
fun Iterable>.partition(): Pair, List> {
val oks = mutableListOf()
val errs = mutableListOf()
forEach {
when (it) {
is Ok -> oks.add(it.value)
is Err -> errs.add(it.reason)
}
}
return Pair(oks, errs)
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy