Skip to content

Instantly share code, notes, and snippets.

@LenKIM
Created July 19, 2019 12:33
Show Gist options
  • Save LenKIM/99eb751ccab817a085f492ead0ecca55 to your computer and use it in GitHub Desktop.
Save LenKIM/99eb751ccab817a085f492ead0ecca55 to your computer and use it in GitHub Desktop.
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