Nir
12/19/2020, 5:05 PMval finalSet = whateverlist.fold(mutableSetOf()) { acc, element ->
val individualSet = someCode(element)
acc.apply { addAll(individualSet) }
}
I'd expect this to be a little faster than some of the other approaches (e.g. reduce with regular Set and union
)randomcat
12/19/2020, 5:09 PMsomeList.flatten().toSet()
would work well enoughrandomcat
12/19/2020, 5:10 PMasSequence()
if you thought it was necessaryNir
12/19/2020, 5:15 PMNir
12/19/2020, 5:33 PMrandomcat
12/19/2020, 5:34 PMNir
12/19/2020, 5:34 PM