title: Kotlin: Iterate through a list and combine same items
body: <p>I'm writing an android app using Kotlin. I have a mutable list of strings and I want to iterate through that list in order to combine the same strings and show how many times they appear in the same order.
  For example,</p>
  <pre><code>current list = [a,b,b,b,c,d,d,a,a,b,b,c]
  </code></pre>
  <p>I want the new list to look like this:</p>
  <pre><code>new list = [a,(b) 3 times,c,(d) 2 times,(a) 2 times,(b) 2 times,c]
  </code></pre>
  <p>I know I can do this using a for-each loop but I can't seem to think of how as I'm new to programming. Would really appreciate if someone could help me with this!</p>