title: Scala Sequence to a Sequence of Sequence
body: <p>I have a Sequence as:</p>
  
  <pre><code>Seq(1,2,3) 
  </code></pre>
  
  <p>I'm trying to get a Sequence of a Sequence that would look like this:</p>
  
  <pre><code>Seq(Seq(1), Seq(1,2), Seq(1,2,3))
  </code></pre>
  
  <p>Here is what I came up with:</p>
  
  <pre><code>  def pop(acc: Seq[Seq[Int]], elems: Seq[Int]): Seq[Int] = elems match {
      case Nil =&gt; acc.flatten
      case x :: xs =&gt;
        pop(acc ++ Seq(Seq(x, xs.head)), xs.tail)
    }
  </code></pre>
  
  <p>As expected, I'm hitting a NoSuchElementException on the place where I do xs.head. I'm sure there must be something that I"m doing wrong! May be I'm missing. This one does not give me the expected result, but this was just a try!</p>
  
  <p>Edit: The original goal was to split a String that comes in as:</p>
  
  <p>"1.2.3" to a Sequence of Strings as Seq("1), Seq("1.2"), Seq("1.2.3")</p>
  
  <p>To achieve this, I'm first splitting based on the . character, going over the resulting Sequence and concatenating them again with the . character.</p>