title: How to create List from Range
body: <p>I am new to Scala, just started learning, so this is basic beginner question.</p>
  
  <p>I try to implement <a href="http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes" rel="noreferrer">Sieve of Eratosthenes</a> algorithm. Here is what I got so far:</p>
  
  <pre>
  def sieve_core(cross: Int, lst: Seq[Int]): List[Int] = {
      val crossed = lst.filter(_ % cross != 0)
      crossed match {
              case a :: rest => cross :: sieve_core(a, crossed)
              case _ => cross :: Nil
      }
  }
  
  def sieve(max: Int): List[Int] = {
      sieve_core(2, (2 to max))
  }
  
  println(sieve(100))
  </pre>
  
  <p>The result is:</p>
  
  <pre>
  List(2)
  </pre>
  
  <p>As far as I understand, <code>case _ => cross :: Nil</code> is matched in first iteration of <code>sieve_core</code>, which means that <code>crossed</code> is not an instance of a List.</p>
  
  <p>I changed <code>lst</code> parameters type to <code>List[Int]</code> and now the code won't compile with an error:</p>
  
  <pre>
  (fragment of Problem3.scala):24: error: type mismatch;
   found   : Range.Inclusive
   required: List[Int]
      sieve_core(2, (2 to max))
                        ^
  </pre>
  
  <p>Apparently <code>Range</code> is not a <code>List</code>.</p>
  
  <p>Question: how can I turn Range into a List? Or is it some bigger problem with my code, I have made some bad assumption somewhere along the way?</p>
  
  <p>Any help appreciated.</p>