Created
July 17, 2015 04:46
-
-
Save shigemk2/15fa7908e51acb9bf8db to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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