Skip to content

Instantly share code, notes, and snippets.

@spoertsch
Created October 9, 2013 18:15
Show Gist options
  • Save spoertsch/6905678 to your computer and use it in GitHub Desktop.
Save spoertsch/6905678 to your computer and use it in GitHub Desktop.
IPSWAYS Scala Meetup - Partial function vs. Currying
def lessThan(max: Int, value: Int) = value < max
//> lessThan: (max: Int, value: Int)Boolean
lessThan(5, 10)
//> res0: Boolean = false
// Partial applied functions
val lessThan5 = lessThan(max = 5, _: Int)
//> lessThan5 : Int => Boolean = <function1>
lessThan5(10)
//> res1: Boolean = false
// Curried function
def lessThanCurried(max: Int)(value: Int) = value < max
//> lessThanCurried: (max: Int)(value: Int)Boolean
lessThanCurried(5)(10)
//> res2: Boolean = false
val lessThan5Curried = lessThanCurried(5)_
//> lessThan5Curried : Int => Boolean = <function1>
lessThan5Curried(10)
//> res3: Boolean = false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment