<In Kotlin, How to groupBy only subsequent items?>...
# stackoverflow
u
In Kotlin, How to groupBy only subsequent items? I want to groupBy a list of items by its value, but only if subsequent, and ignore grouping otherwise: input: val values = listOf("Apple", "Apple", "Grape", "Grape", "Apple", "Cherry", "Cherry", "Grape") output: {"Apple"=2, "Grape"=2, "Apple"=1, "Cherry"=2, "Grape"=1}