https://kotlinlang.org logo
#arrow
Title
k

kds

04/09/2019, 5:21 AM
Copy code
fun <A> flat(listOfOptions: List<Option<A>>): List<A> {
        return listOfOptions.fold(mutableListOf(), { acc, opt ->
            when (opt) {
                is Some -> {
                    acc.add(opt.t)
                    acc
                }
                is None -> acc
            }
        })
    }