Skip to content

Instantly share code, notes, and snippets.

@khebbie
Last active July 6, 2016 19:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save khebbie/0f8c98de3524bb6a949741fa004b1e2c to your computer and use it in GitHub Desktop.
Save khebbie/0f8c98de3524bb6a949741fa004b1e2c to your computer and use it in GitHub Desktop.
Chapter 2 in "Functional programming in Scala"
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