title: How do I remove duplicate values from my Multidimensional array in a Scala way?
body: <p>I'm trying extract some values from a String. The string contains several lines with values. The values on each line are number, firstname, last name. Then I want to filter by a given pattern and remove the duplicate numbers.</p>
  
  <p><strong>This is my test:</strong></p>
  
  <pre><code>test("Numbers should be unique") {
      val s = Cool.prepareListAccordingToPattern(ALLOWED_PATTERN, "1234,örjan,nilsson\n4321,eva-lisa,nyman\n1234,eva,nilsson")
      assert(s.length == 2, "Well that didn't work.. ")
      info("Chopping seems to work. Filtered duplicate numbers. Expected 1234:4321, got: "+s(0)(0)+":"+s(1)(0))
    }
  </code></pre>
  
  <p><strong>The methods:</strong></p>
  
  <pre><code>def prepareListAccordingToPattern(allowedPattern: String, s: String) : Array[Array[String]] = {
      val lines = chop("\n", s)
      val choppedUp = lines.map(line =&gt;
        chop(",", line)).filter(array =&gt;
          array.length == 3 &amp;&amp; array(0).matches(allowedPattern)
        )    
      choppedUp
  }
  
  def chop(splitSymbol: String, toChop: String) : Array[String] = {
      toChop.split(splitSymbol)
    }
  </code></pre>
  
  <p>My test fails as expected since I receive back a multidimensional array with duplicates:</p>
  
  <p><strong>[0]["1234","örjan","nilsson"]</strong></p>
  
  <p>[1]["4321","eva-lisa","nyman"]</p>
  
  <p><strong>[2]["1234","eva","nilsson"]</strong></p>
  
  <p>What I would like to do is to filter out the duplicated numbers, in this case <strong>"1234"</strong>
  so that I get back:</p>
  
  <p>[0]["1234","örjan","nilsson"]</p>
  
  <p>[1]["4321","eva-lisa","nyman"]</p>
  
  <p>How should I do this in a scala way? Maybe I could attack this problem differently?</p>