All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.natpryce.iterables.kt Maven / Gradle / Ivy

There is a newer version: 2.0.0
Show newest version
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