# Higher-Order Function

> A function that takes another function as input, or gives one back. map is one.

**Field:** Software Development  
**Category:** Programming Paradigms  
**Also known as:** Higher Order Function, HOF

## Think of it like

Think of it like a boss who hands a task to a helper. The boss says what; the helper does it.

## Definition

A higher-order function takes another function as input, or gives one back. map is the best-known one: you hand it a function and a list, and it runs that function on every item. sorted with a key, and filter, work the same way. They let you reuse the looping part and swap only the small action. Most modern languages have them built in.

## Example

Emma passes str.upper to map with a list of two letters. Without writing a loop, she gets both letters in capitals.

## Example code

```python
>>> list(map(str.upper, ["a", "b"]))
['A', 'B']
```

map takes a function and runs it on each item.

## Why it matters

They remove a lot of copy-pasted loops. One line says what to do to every item.

## Common mistake

Calling the function while you pass it, like map(str.upper(), items). Pass just the name.

## Three principles

- **Takes a function.** Or gives one back.
- **Reuse the loop.** Swap only the action.
- **map, filter, sort.** The common ones.

## Related terms

- [Map, Filter and Reduce](https://learn.benibix.com/term/development/map-filter-reduce)
- [Lambda Function](https://learn.benibix.com/term/development/lambda)
- [Callback Function](https://learn.benibix.com/term/development/callback)
- [Function](https://learn.benibix.com/term/development/function)
- [First-Class Function](https://learn.benibix.com/term/development/first-class-function)

## Told apart from

- [First-Class Function vs Higher-Order Function](https://learn.benibix.com/compare/first-class-function-vs-higher-order-function): With first-class functions, a function is a value you can store and pass. A higher-order function is one that takes in or hands back a function.

---

Source: https://learn.benibix.com/term/development/higher-order-function
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-17
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
