tips in Functional Programming in Scala

update everyday(maybe weekly)

  • partial application

    1
    2
    3
    4
    5
    6
    7
    8
    9
    def compose[A,B,C](f: B => C, g: A => B): A => C = {
    (a: A) => f(g(a))
    }
    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)
    }