> For the complete documentation index, see [llms.txt](https://calnotes.gitbook.io/cs61a-guidebook/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://calnotes.gitbook.io/cs61a-guidebook/building-blocks/higher-order-functions.md).

# Higher-Order Functions

Travelling First-Class.

Python treats functions like "first-class citizens". This means that the language supports passing functions as arguments to other functions, returning them as the values from other functions, and assigning them to variables or storing them in data structures.&#x20;

Higher-order functions are functions that accept a function as an argument and/or return a function as a value. For example,

```python
def f(x):
    def g(y):
        return x + y
    return g
```

Here, `f` would be a higher-order function — since it returns another function `g`.
