Function Currying (And Uncurrying) In Swift

NOT food related

Steven Curtis
4 min readFeb 8, 2022
Photo by Clark Tibbs on Unsplash

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.

--

--

No responses yet