11.7.2. Built-in Functions: apply(), filter(), map(), reduce()
In this section, we will look at the apply(), filter(), map(), and reduce() built-in functions as well as give some examples to show how they can be used. These functions provide the functional programming features found in Python. A summary of these functions is given in Table 11.1. All take a function object to somehow invoke.
Built-in Function | Description |
---|---|
apply(func[, nkw][, kw]) | call func with optional arguments, nkw for non-keyword arguments and kw for keyword arguments; the return value is the return value of the function call |
filter(func, seq) | invokes Boolean function func iteratively over each element of seq; returns a sequence ... |
Get Core Python Programming now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.