Last active
July 6, 2016 19:40
-
-
Save khebbie/0f8c98de3524bb6a949741fa004b1e2c to your computer and use it in GitHub Desktop.
Chapter 2 in "Functional programming in Scala"
This file contains 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
package chapter2 | |
object MyMain{ | |
def partial1[A,B,C](a:A, f: (A,B)=> C):B=>C={ | |
(b:B)=> f(a,b) | |
} | |
def curry[A,B,C](f: (A,B)=> C): A=> (B=>C)={ | |
(a:A) => (b:B)=> f(a,b) | |
} | |
def unCurry[A,B,C](f: A=>B=>C): (A,B) =>C ={ | |
(a:A,b:B)=> f(a)(b) | |
} | |
def compose[A,B,C](f: B=>C, g: A=> B): A=> C ={ | |
(a:A) => f(g(a)) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment