redrield
07/08/2018, 3:41 PMList<List<T>>
, is there a way to flatten it while adding items at the boundaries between the lists?karelpeeters
07/08/2018, 3:48 PMredrield
07/08/2018, 3:49 PMval list = listOf(
listOf("a", "b", "c"),
listOf("d", "e", "f")
)
and I call this imaginary function, say the joining element is "|", I want it to return listOf("a", "b", "c", "|", "d", "e", "f")
karelpeeters
07/08/2018, 3:51 PMlist.reduce { acc, list -> acc + "|" + list }
kz
07/08/2018, 3:51 PMval list = listOf(
listOf("a", "b", "c"),
listOf("d", "e", "f")
)
println(list.reduce { a, b -> a + "|" + b })
redrield
07/08/2018, 3:54 PMkarelpeeters
07/08/2018, 3:54 PMredrield
07/08/2018, 3:55 PMkarelpeeters
07/08/2018, 3:55 PMredrield
07/08/2018, 4:04 PMkarelpeeters
07/08/2018, 5:50 PM