title: Create list from vector in scala
body: <p>I am stumped on something pretty basic in Scala. I'm working my way through the book "Atomic Scala." I'm not a complete beginner to programming, but what experience I do have is pretty surface-level. No actual development experience, just tinkering around with string manipulation and things at that level. </p>
  
  <p>In the book, one of the exercises (in a section on Parameterized Types) is to define a method which takes a vector as input and gives a list as output, where the list's elements are the same as the vector's elements. The given vector could be of any length.</p>
  
  <p>I don't know of a way to do this without a for loop and without thinking of the list as (at least at first) mutable.</p>
  
  <p>Here's what I tried:</p>
  
  <pre><code>def explicit(v:Vector[Double]):List[Double] = {
      var l = List()
      for (i &lt;- v) {
          l = l :+ i
      }
      l
  }
  </code></pre>
  
  <p>but it appears there's something wrong with that fourth line. It kicks out an error message.</p>
  
  <p>I have a feeling there's some cool thing you can do without a for loop where you just say right off the bat "val l = List(~~~insert something cool here with rockets or something~~~) but either the book hasn't covered this yet or I just haven't figured it out.</p>
  
  <p>As you can see, I'm at a very basic level here, so please do your best to explain it like I'm five. ;)</p>
  
  <p>Edited to add: I looked ahead a little bit, and it looks like a couple of chapters later I'll be learning about the "map" method, which if I'm skimming accurately, would provide a solution to this problem. But that's later in the book. Any idea how it can be done without map?</p>