Skip to content

Instantly share code, notes, and snippets.

@notyy
Created May 28, 2012 15:17
Show Gist options
  • Save notyy/2819682 to your computer and use it in GitHub Desktop.
Save notyy/2819682 to your computer and use it in GitHub Desktop.
applicative
def connect[A,B,C](f1: A => B, f2: A => B, f3: B => B => C): (A => C) = x => {
f3(f1(x))(f2(x))
}
def add2 = (x:Int) => x + 2
def multi3 = (x:Int) => x * 3
def addThem = (x:Int) => (y:Int) => x + y
val f = connect(add2, multi3, addThem)
//what's the result
f(3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment