Skip to content

Instantly share code, notes, and snippets.

@Rafailong
Created March 22, 2019 17:45
Show Gist options
  • Save Rafailong/dcb1e67c1245776c136482d3c9d49c7e to your computer and use it in GitHub Desktop.
Save Rafailong/dcb1e67c1245776c136482d3c9d49c7e to your computer and use it in GitHub Desktop.
path to fp - currying
// base function
def add(a: Int, b: Int): Int = a + b
// curried form
def addCurried(a: Int)(b: Int): Int = a + b
/**
* In scala functions have the method `curried`
*/
val addCurriedTwo = (add _).curried
println(addCurriedTwo(1)(1)) // 2
val min: Int => Int => Int = x => y => if (x <= y) x else y
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment