Skip to content

Instantly share code, notes, and snippets.

@krishnabhargav
Last active August 29, 2015 14:08
Show Gist options
  • Save krishnabhargav/b1a506a2bdbc1e573703 to your computer and use it in GitHub Desktop.
Save krishnabhargav/b1a506a2bdbc1e573703 to your computer and use it in GitHub Desktop.
implementing currying ... chapter 2 ... FP in Scala
def curry[A,B,C] (f: (A,B) => C): A => (B => C) = a => b => f(a,b)
curry((a:Int, b:Int) => a * b)(1)(2)
def uncurry [A,B,C] (f: A => B => C) : (A,B) => C = (a,b) => f(a)(b)
var f = uncurry (curry((a:Int, b: Int) => a * b)) // f (3,5) = 15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment