higher-order function

In programming, a higher-order function is a function that either takes one or more functions as arguments or returns a function as its result. This powerful feature allows you to create more abstract and flexible code.

Higher-order functions are a cornerstone of functional programming, enabling you to use functions like map(), filter(), and lambda function to manipulate data in a clean and expressive way.

You can often replace loops with higher-order functions for writing more concise and readable code. This can make your code more modular and maintainable.

Example

Here’s a quick example of using map(), which is a higher-order function in Python:

Python
>>> def square(base):
...     return base**2
...

>>> list(map(square, [1, 2, 3, 4, 5]))
[1, 4, 9, 16, 25]

In this example, map() takes the square() function and applies it to each element in the provided list, resulting in a new list of square values.

Tutorial

Functional Programming in Python: When and How to Use It

In this tutorial, you'll learn about functional programming in Python. You'll see what functional programming is, how it's supported in Python, and how you can use it in your Python code.

intermediate python

For additional information on related topics, take a look at the following resources:


By Leodanis Pozo Ramos • Updated April 16, 2025
OSZAR »