Scala performance - Sieve
问题 Right now, I am trying to learn Scala . I've started small, writing some simple algorithms . I've encountered some problems when I wanted to implement the Sieve algorithm from finding all all prime numbers lower than a certain threshold . My implementation is: import scala.math object Sieve { // Returns all prime numbers until maxNum def getPrimes(maxNum : Int) = { def sieve(list: List[Int], stop : Int) : List[Int] = { list match { case Nil => Nil case h :: list if h <= stop => h :: sieve