Is there some standard functional way of grouping ...
# announcements
s
Is there some standard functional way of grouping consecutive elements that are similar somehow
listOf("str", "str", 2, "str")
into sublists based on ie.
.class
so the example would become
listOf(listOf("str", "str"), listOf(2), listOf("str"))
d
spand:
list.groupBy { it.javaClass }.values.toList()
Ok, with the edit my easy solution does not quite work anymore 😄
s
They would have to be consequtive
yes
I am trying to reverse a flatten
k
I think you need a fold
s
Thanks @kirillrakhman. That turned out quite alright