Instructor: First, let's define a couple of functions we're going to be working on. + is a function that takes two arguments and returns their sum. < is a function that takes two arguments and returns a Boolean, indicating whether the first is smaller than the second.

Now, imagine that at a certain point working on our important project, we come upon many, many Ys that we wish to transform in the same way, for example, by adding one to each of them. Rather than saying +1Y, +1Y over and over again, we write a function to do that for us.

When we pass one to the function, we obtain two. When we pass three to the function, we obtain four. The function is called +1, because it takes a single argument, passes it to the plus function as the second argument, and passes a fixed number one to the plus function as its first argument.

Quite often, the large data set that we wish to work on is contained in an array. Here is our first higher order function. It's called a higher order function, because it takes at least one function as an argument. Here's how we use it.

We've mapped the +1 function over the incoming array to produce a new array whose values are the result of applying the function to each of the values in the original array. Now, let's do the same thing with our < function.

The function takes a single argument, and tells us whether two is less than that argument. When we pass one to it, two is not less than one, and we obtain false. When we pass three to it, two is less than that, so we obtain true. Let's map this function over the input array.

We obtain a new array, whose values are the same as those we obtained by applying the functions to the elements individually, but when we have a predicate and an array, the thing we're really interested in is producing a new array that contains only the elements for which the predicate return true.

For that, we use our second higher order function filter. We construct a function that given an array will filter that array based upon the predicate. We see that the original one, since the predicate returned false is not present in the output array, and the original three for which the predicate returned true is.