Created
May 28, 2012 15:17
-
-
Save notyy/2819682 to your computer and use it in GitHub Desktop.
applicative
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 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