Last active
December 28, 2019 16:27
-
-
Save kadirmalak/c9c223e4c78bf7d82969bd095c361b26 to your computer and use it in GitHub Desktop.
currying-demo-1
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
// if we do not use currying... | |
// this is the sample test code | |
def testSomething(something: String, var1: Double, var2: String) = { | |
println(something + ", var1: " + var1 + ", var2: " + var2) | |
} | |
// this function runs a function with possible variations | |
def runWithVariations1(v1s: List[Int], v2s: List[String], f: (Double, String) => Unit) = { | |
for (v1 <- v1s; | |
v2 <- v2s) { | |
f(v1, v2) | |
} | |
} | |
runWithVariations1( | |
List(1, 2, 3), // var1 values | |
List("a", "b", "c"), // var2 values | |
(var1: Double, var2: String) => { testSomething("some case", var1, var2) } // lambda func that takes var1 and var2 | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment