Created
July 17, 2018 12:51
-
-
Save gekomad/f865e238ce3f1304a69b5e5650854821 to your computer and use it in GitHub Desktop.
Currying Haskell / Scala
This file contains 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
module Currying where | |
addF :: Integer -> Integer -> Integer | |
addF a b = a + b | |
res = addF 1 2 | |
main :: IO () | |
main = print res |
This file contains 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 f1(a: Int): Int => Int = { | |
def f2(b: Int): Int = { | |
a + b | |
} | |
f2 _ | |
} | |
def addF(a: Int, b: Int) = { | |
val p: Int => Int = f1(a) | |
val s: Int = p(b) | |
s | |
} | |
println(addF(1, 2)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment