I try to understand the function currying tutorial but that code seem out of date. And it's still not really clear about function currying.
I try with this function:
func curry<A, B, C>(_ f: @escaping (A, B) -> C) -> (A) -> (B) -> C {
return { a in { b in f(a, b)} }
}
And it runs ok with Playground (Xcode 9 beta 6)
. But the problem is I cannot use this function as the tutorial:
let add = curry(+)
let xs = 1...100
let x = xs.map(add(2))
The code above return error:
Playground execution failed:
error: FunctionsCurrying.playground:31:17: error: ambiguous use of operator '+'
let add = curry(+)
^
Please correct me and help me to clear about function currying
.