Higher-order functions

Higher-Order Functions (HOF) are the Higher-order functions (HOF) represent the third fundamental block of functional programming after closures and iterators. We can consider HOFs to be the glue between the other two.

HOFs are functions that take other functions as arguments and, optionally, can return functions.

HOFs can take many forms. Here’s an example with a single argument and function return, with generics in place:

fn hof<A, B>(fun: Fn(A) -> B) -> Box<Fn(A) -> B >

Again, this is just a generic example.

Let’s take a look at HOFs at work in some concrete applications.

Get hands-on with 1200+ tech skills courses.