Skip to content

Instantly share code, notes, and snippets.

@kadirmalak
Last active December 28, 2019 16:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kadirmalak/c9c223e4c78bf7d82969bd095c361b26 to your computer and use it in GitHub Desktop.
Save kadirmalak/c9c223e4c78bf7d82969bd095c361b26 to your computer and use it in GitHub Desktop.
currying-demo-1
// 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