According to Wikipedia:
currying is the technique of translating the evaluation of a function that takes multiple arguments (or a tuple of arguments) into evaluating a sequence of functions, each with a single argument.
Given a function f:
func f(x: Int, y: Int, z: Int)
which you normally call with
f(x: 1, y: 2, z: 3), you turn it into a series of functions that you can call in these order with currying:
let f0 = curry(f) let f1 = f0(1) let f2 = f1(2) let result = f2(3)
This is useful, for e.g., because you can create the functions stored in
f2 as you process and gather the arguments.
While an alternative is just to store the values of
y as we gather them in an object, as we write more functional code, currying is a very useful technique.