Posts

Showing posts from April, 2018

Higher-Order Programming: Behind the Scenes!

Image
Welcome to Higher-Order Programming! Hi, Welcome! In this section we are going to dive into Higher-Order Programming. You will learn how to pass functions as parameters to other functions and how to return functions from functions. Let’s get started! In the diagram below you can first see two of the functions we will be working with. These are regular functions  f  and  g  that perform a simple operation on their parameter. In the purple rectangle you can find an example of  passing functions as arguments  to other functions. In this case we pass the functions  f  and  g  to the function  h . In the blue rectangle you can find an example of  returning functions  from functions. Let’s look at each one in more detail! : ) Passing Functions as Arguments The function  applyFunctions  takes three parameters ( f ,  g  and  p ).  f  and  g  are functions. We can determine that by looking at the body of the function. See how we call the function  f  with  f(p