title: Remove consecutive identical elements in scala
body: <p>I have a list which may contain certain consecutive identical elements.I want to replace many consecutive identical elements with one. How to do it in scala</p>
  
  <p>Lets say my list is </p>
  
  <pre><code>List(5, 7, 2, 3, 3, 3, 5, 5, 3, 3, 2, 2, 2)
  </code></pre>
  
  <p>I want output list as </p>
  
  <pre><code>List(5, 7, 2, 3, 5, 3, 2)
  </code></pre>