liveBook · Manning

Higher-order function

As explained in The Art of Code

A higher-order function is a function or method that accepts functions as arguments, returns a function, or both.

A higher-order function is a function or method that accepts functions as arguments, returns a function, or both. In Java streams, map and filter accept function-valued arguments: map transforms elements, while filter decides which elements remain. section 6.3.1

Turn a book pipeline into a readable transformation

A verbose approach can separate the operations and increase the reader’s jumping between declarations. A compact pipeline keeps the story in order: books.stream().filter(book -> book.publishedDate().isAfter(LocalDate.now().minusYears(1))).map(Book::author).toList(). The filter keeps recent books; map transforms each remaining Book into its author name. section 6.3.1

Chaining higher-order methods creates transformation stages that read from top to bottom. The pipeline remains lazy, so author extraction does not occur until a terminal operation requests the result. For short, one-shot operations, inline lambdas or method references usually keep the transformation easier to follow; avoid multiline lambda blocks when they obscure the pipeline. section 6.3.1

How The Art of Code covers it

How deep it goes
Defines the concept and demonstrates map, filter, chaining, method references, and lazy evaluation without deeper function-runtime internals.
Examples
Demonstrates recent-book filtering, author extraction, method references, chained streams, and collection with toList().
What it assumes
Assumes familiarity with functions, methods, objects, Java streams, lambdas, and method references.
What you can do after
Apply it via Java streams to express filtering and transformation pipelines as readable, lazy stages.
How it connects
Connects functions with Java streams, lambdas, method references, predicates, mapping, filtering, terminal operations, and lazy evaluation.

Also explained in

Compare how 14 books explain higher-order function →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of The Art of Code. The section links point to the parts of the book it draws on.