Transcript from the "Piping & Composition Exercise" Lesson
>> Kyle Simpson: All right, well, it's time that we practice this candy factory, I mean, composition. So we've got a quick little exercise for you, we're gonna define our own general compose and general pipe function. Rather than having one that can only take 2 or 3 or 4, we wanna write general functions that can take any number 2, 3, 4, 100, however many that we pass.
[00:00:22] You'll notice in the set up for this exercise, we have several functions provided, increment, decrement, double, and half. And then here are your compose and pipe functions that you wanna implement. And you'll notice that you have several functions set up here at the bottom, that's the ones that you're going to test with.
[00:00:39] And so you want to make sure that at the end all of these print true. You'll notice that in each case the compose and the pipe are deliberately set up to be the reverse of each other. So that's why f1(3) should return the same thing as f2(3), because compose with increment,decrement should be the same as pipe with decrement,increment, okay?
[00:01:02] One last little hint in implementing compose and pipe is that you really only need to implement one of these two. Pick either compose or pipe and implement it. And then the other one can be implemented in terms of the previous one but just reversing the list of functions that you pass in.