title: Nil vs List(Nil) in a for with recursion
body: <p>I'm learning Scala and have a quick question: Can someone please explain to me why the following two sets of code yield different results?</p>
  
  <pre><code>def grey0(n: Int): List[List[String]]={
    if (n==0) List(Nil)
    else for(i&lt;-List("0","1"); j&lt;-grey0(n-1)) yield i :: j 
   }
  </code></pre>
  
  <p>versus </p>
  
  <pre><code>def grey1(n: Int): List[List[String]]={
    if (n==0) Nil
    else for(i&lt;-List("0","1"); j&lt;-grey0(n-1)) yield i :: j 
   }
  </code></pre>
  
  <p>The first option yields the result I am looking for. What I don't understand is, why does the second option just return the empty list? I would have thought the other results would cons on to it and if anything, I would get some sort of flat list rather than a <code>List[List[String]]</code> (which is what I want).</p>