From the course: Learning Functional Programming with Swift

Unlock the full course today

Join today to access over 22,500 courses taught by industry experts or purchase this course individually.

Partial application

Partial application - Swift Tutorial

From the course: Learning Functional Programming with Swift

Start my 1-month free trial

Partial application

- [Instructor] The first advanced concept I'll introduce you to is called partial application. In simple terms, partial application is when we take a function that has more than one argument and we fix one of those arguments to a set value, producing a function that has one less argument. So what does this look like in code? If you remember, this is the same kind of thing that we did in our discussion about returning functions. Let's imagine that we have a simple add function that takes three numbers as arguments and adds them together. That will look like this, function, add, our first argument, it's an integer. Our second argument is an integer, and our third argument is an integer. And finally, our function is going to return an integer. And inside our function, we return x plus y plus z, all three of our arguments added together. What if we wanted to fix one of these arguments to a certain number so that we only had to pass in two arguments later on? What that would look like is…

Contents