# Higher-Order Functions

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`.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://calnotes.gitbook.io/cs61a-guidebook/building-blocks/higher-order-functions.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
