Created
April 16, 2019 15:38
-
-
Save Rafailong/267713ef0145acb1c248aab9a9dc29bd to your computer and use it in GitHub Desktop.
path to fp - partial function applicaiton
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
val addCurried: Int => Int => Int = (add _).curried | |
print(addCurried(1)(2)) |
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 addPrime(a: Int)(b: Int): Int = a + b | |
println(addPrime(1)(1)) | |
val add2Prime: Int => Int = addPrime(2)_ | |
println(add2Prime(2)) |
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
// we define our base function | |
def add(a: Int, b: Int): Int = a + b | |
println(add(1,2)) |
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
val add3: Int => Int = add(3, _: Int) |
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 add2(b: Int): Int = add(2, b) | |
println(add2(2)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment