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

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

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.

Last updated