Created
July 19, 2019 12:33
-
-
Save LenKIM/99eb751ccab817a085f492ead0ecca55 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
object curringTest extends App { | |
def filter(xs: List[Int], p: Int => Boolean): List[Int] = | |
if (xs.isEmpty) xs | |
else if (p(xs.head)) xs.head :: filter(xs.tail, p) | |
else filter(xs.tail, p) | |
def modN(n: Int)(x: Int) = (x % n) == 0 | |
val nums = List(1,2,3,4,5,6,7,8) | |
println(filter(nums, modN(2))) | |
println(filter(nums, modN(3))) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment