Last active
August 29, 2015 14:08
-
-
Save krishnabhargav/b1a506a2bdbc1e573703 to your computer and use it in GitHub Desktop.
implementing currying ... chapter 2 ... FP in Scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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