Created
November 3, 2018 21:59
-
-
Save dorsev/c0f4e372d4d209473b3f6e538e1a4a7e to your computer and use it in GitHub Desktop.
Eta Expansion in scala - p2
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
scala> val etaexplained = emphasisFunc _ | |
etaexplained: String => String = $$Lambda$1239/712726821@5a5b394 | |
//what happens on multiple paramters list ? | |
//they get curried away. | |
//for example | |
scala> def strAddByNumAndMultiplty(str:String)(numToAdd:Int)(numToMultiply:Int) = str.toInt + numToAdd * numToMultiply | |
strAddByNumAndMultiplty: (str: String)(numToAdd: Int)(numToMultiply: Int)Int | |
scala> strAddByNumAndMultiplty _ | |
res5: String => (Int => (Int => Int)) = $$Lambda$1286/1637214165@f2120d5 | |
scala> strAddByNumAndMultiplty _ | |
res5: String => (Int => (Int => Int)) = $$Lambda$1286/1637214165@f2120d5 | |
scala> val func = strAddByNumAndMultiplty _ | |
func: String => (Int => (Int => Int)) = $$Lambda$1287/795982694@4d8e6daa | |
scala> func("1")(2)(3) | |
res6: Int = 7 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment