groostav
08/03/2019, 11:52 PMList<List<T>>
which can be conceptualized as a "list of columns", (where each inner List<T>
is a column), whats the most elegant collection method to use to get a list of rows?molikuner
08/04/2019, 12:49 AMlist.map { it[index] }
.
EDIT: Sorry, understood that question wrong.karelpeeters
08/04/2019, 6:33 AMlist.first().indiches.map { i -> list.map{ it[i] } }
molikuner
08/04/2019, 7:34 AMlist.flatMap { row -> row.mapIndexed { index, t -> index to t }}. groupBy({ it.first}) { it.second }.values
This sould return a list of rows, even when they aren't the same length or sth. is empty. But if you know, that the columns are all the same length, you should use Karels solution. It's way more efficient.Dico
08/04/2019, 10:30 AM