title: Scala: Yielding from one type of collection to another
body: <p>Concerning the <em>yield</em> command in Scala and the following example:</p>
  
  <pre><code>val values = Set(1, 2, 3)
  val results = for {v &lt;- values} yield (v * 2)
  </code></pre>
  
  <p>
  <li>Can anyone explain how Scala knows which type of collection to yield into? I know it is based on <em>values</em>, but how would I go about writing code that replicates <em>yield</em>?</li>
  <li>Is there any way for me to change the type of the collection to yield into? In the example I want <em>results</em> to be of type <em>List</em> instead of <em>Set</em>.</li>
  <li>Failing this, what is the best way to convert from one collection to another? I know about _:*, but as a <em>Set</em> is not a <em>Seq</em> this does not work. The best I could find thus far is <em>val listResults = List() ++ results</em>.</p>
  
  <p>Ps. I know the example does not following the recommended functional way (which would be to use <em>map</em>), but it is just an example.</p>