From the course: Functional Programming with PHP

Unlock the full course today

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

Composition, part 1

Composition, part 1 - PHP Tutorial

From the course: Functional Programming with PHP

Start my 1-month free trial

Composition, part 1

- [Narrator] The last advanced functional concept we're going to look at in this course is something called composition. Now you may remember that much earlier in this course, when we were first learning about first class functions, we created an array of functions and used this array of functions to transform some piece of data in some way. This allowed us to avoid having several nested functions, where some function was called and the result of inner function, which was called in the result of another inner function, and so on. So roughly speaking, composition is when we take a series of smaller, modular functions and combine them into one more complex function. In the example that we saw earlier in this course, we took some very simple mathematical functions, such as doubling or subtracting one from a number, and combined them into a more complex mathematical function. And this was a good basic example of composition,…

Contents