<@U6P03BM0W> There's no one-liner for that, but yo...
# announcements
i
@dave08 There's no one-liner for that, but you can implement this operation with the help of `associateBy`:
Copy code
fun <F,S,K> setPartition(
				first: Iterable<F>,
				second: Iterable<S>,
				firstGetKey: F.() -> K,
				secondGetKey: S.() -> K
		): List<Triple<K, F?, S?>>
{
    val firstByKey = first.associateBy(firstGetKey)
    val secondByKey = second.associateBy(secondGetKey)
    val allKeys = firstByKey.keys + secondByKey.keys
    return allKeys.map { Triple(it, firstByKey[it], secondByKey[it]) }
}
d
@ilya.gorbunov When the key is missing in first, or in second, the triple should have the key, the value of the object that exists and null for the one missing... That's what complicates things. Also wondering if first is a set of 50 to 100 objects and B is 5 to about 50 objects, in a framework like Vert.x with lots of requests coming in, and a pipeline of processing on the triple, would the coroutine version perform better? The stdlib version is almost always more readable and less error prone...
i
d
@ilya.gorbunov Oh, now I noticed that it would work fine.. I'm on my tablet so I can't check 😊 What about performance?
i
I expect coroutine version to be slower. You can measure yourself how much by writing a benchmark.
d
Thanks, I'll check!