@aamit01: Nothing ready at the moment in the standard library, but we're considering to add a function like this. Meanwhile, you can also try something like
Copy code
val result = mutableMapOf<String, Int>().apply {
w1.split(" ").forEach { put(it, getOrElse(it) { 0 } + 1) }
}