Created
September 21, 2022 12:28
-
-
Save mcalavera81/7895f565c0a69ce1ee44a112ae945bfe to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val raw: List<Char> = "aabcccccaaa".map { it } | |
println(raw.toList().fold(listOf<Char>()) { acc, value -> | |
if (acc.isEmpty()) listOf(value) | |
else {//a2, b | |
if (acc.last() == value) acc | |
else acc + value | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment