Skip to content

Instantly share code, notes, and snippets.

@zsxwing
Created April 8, 2013 02:43
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 zsxwing/5333841 to your computer and use it in GitHub Desktop.
Save zsxwing/5333841 to your computer and use it in GitHub Desktop.
Currying example.
object CurryTest {
def modN(n: Int)(x: Int) = x % n == 0 //> modN: (n: Int)(x: Int)Boolean
val nums = List(1, 2, 3, 4, 5, 6, 7, 8) //> nums : List[Int] = List(1, 2, 3, 4, 5, 6, 7, 8)
println(nums.filter(modN(2))) //> List(2, 4, 6, 8)
println(nums.filter(modN(3))) //> List(3, 6)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment