Out of curiosity, is there an idiomatic way of fil...
# announcements
r
Out of curiosity, is there an idiomatic way of filtering lists by adjacent distinction? e.g.
Copy code
listOf("a", "b", "b", "a", "b").distinctFromAdjacent()
// result a,b,a,b
r
maybe
Copy code
listOf("a", "b", "b", "a", "b")
    .windowed(2, partialWindows = true)
    .filter { it.size == 1 || it[0] != it[1] }
    .map { it[0] }
r
I did not know about
windowed
thanks!
👍 1