Browse Clojure Foundations for Java Developers

Common Higher-Order Functions

The everyday tools: map, filter, reduce, into, comp, partial, and friends.

Most Clojure code is built from a small toolkit of higher-order functions. If you learn these well, you can read a large percentage of real codebases without feeling lost.

The core set to internalize

  • map, filter, remove, keep for sequence transformations.
  • reduce when you need to combine a sequence into a single result.
  • into when you want a concrete collection at the end of a pipeline.
  • comp and partial for composition and specialization.

Java mental model: similar to the core Stream operators, but these functions are used everywhere, not only in a “stream” context.

In this section, focus on reading: given a pipeline, can you say what value flows between steps and what type of thing comes out at the end?

In this section

  • Using `map` for Transformation
    Learn when `map` is the right tool in Clojure, how it differs from Java loop and stream habits, and how to use it clearly with single and multiple collections.
  • Aggregating Data with `reduce`
    Learn how `reduce` combines a collection into one result, how to choose the right accumulator shape, and how it differs from loops and stream reduction in Java.
  • Filtering Collections with `filter`
    Learn how `filter` keeps matching items in a Clojure pipeline, how laziness affects it, and how it differs from Java loops and stream filtering.
Revised on Friday, April 24, 2026