Skip to content

Instantly share code, notes, and snippets.

@stephenLee
Created September 17, 2012 13:18
Show Gist options
  • Save stephenLee/3737211 to your computer and use it in GitHub Desktop.
Save stephenLee/3737211 to your computer and use it in GitHub Desktop.
Defining and invoking a curried function.
def curriedSum(x: Int)(y: int) = x + y
curriedSum(1)(2) // 3
def first(x: Int) = (y: Int) => x + y
val second = first(1)
second(2) // 3
// use placeholder notation to use curriedSum in a partially applied function
val onePlus = curriedSum(1)_
onePlus(2) // 3
val twoPlus = curriedSum(2)_
onePlus(2) // 4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment