You may have seen in math classes that it can be useful to compose multiple functions together. In computer science, this basically means that we want to take the output of one function and pass it into the input of another. You have been given the block
compose, which does just that. It takes in two functions, f
and g
and returns the
function f(g)
. For example, this
will return a function that is equivalent to
For example
will return 18
(the result of the calculation 2 * (6 + 3)
). Notice that when we call
ed
the result of compose
, we didn't use
a gray border. This is because compose
already returns a function.
Now try writing
which returns the result of composing the functions in the input list, from left to right. So, when called like this
a function equivalent to this
will be returned.
If you have extra time, edit the compose
block and see if you can understand how it's implemented.