Function Currying (And Uncurrying) In Swift
NOT food related
Many blog article seems to think that function currying is something to do with a cooking process. Unfortunately sauce has little to do with this language feature!
However currying can be necessary in order to compose higher-order functions and useful in a conceptual way when writing Swift code.
The currying func
declaration has been removed from Swift. This means rather than using currying declaration syntax we can explicitly return a closure.
Let us explain this all. Let’s go!
Difficulty: Beginner | Easy | Normal | Challenging
Prerequisites:
None in particular! I touch on reduce later in the article, as is generics.
The Mathematical Technique
Currying is a technique for converting a function that takes multiple arguments into a sequence of functions that each take a single argument.