Skip to content

Instantly share code, notes, and snippets.

@shigemk2
Created July 17, 2015 04:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shigemk2/15fa7908e51acb9bf8db to your computer and use it in GitHub Desktop.
Save shigemk2/15fa7908e51acb9bf8db to your computer and use it in GitHub Desktop.
def sieve(xs: List[Int]): List[Int] = xs match {
case xs if xs.isEmpty => Nil
case (x::xs) => x :: sieve(xs.filter(_ % x != 0))
}
println(sieve(Range(2, 100).toList))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment