Starting Files
Download this playground with the problem inside!
The Problem
/// Challenge: We can transform multipleargument functions into a chain of singleargument functions by taking advantage of nested functions. Write a function returnCurriedMathFunc that will curry a two argument math function. See the tests if you're not sure what this means.
/**
Return a curried version of twoParamFunc.
 Parameter twoParamFunc: A math function that takes in two Ints.
 Returns: a curried version of twoParamFunc.
*/
func returnCurriedMathFunc(twoParamFunc: @escaping ((Int, Int) > Int)) > ((Int) > ((Int) > Int)){
// Return a curried version of the given function!
}
// EXAMPLE OF HOW THIS IS USED
func add(x:Int, y:Int) > Int{
return x+y
}
let curriedAdd = returnCurriedMathFunc(twoParamFunc: add)
let addThree = curriedAdd(3)
addThree(2) // Evaluates to 5
We can transform multipleargument functions into a chain of singleargument functions by taking advantage of nested functions.
Write a function returnCurriedMathFunc that will curry a two argument math function. See the example if you’re not sure what this means.
You are not allowed to declare any variables or constants!
Hint: Look at the example of how the curried function is used.
How many function calls are there in total? How many nested functions should you write?
Upload your screenshot here!
Upload files





