Browse Clojure Foundations for Java Developers

Returning Functions from Functions

Closures, partial application, and building small function factories.

In Clojure, it is normal for a function to return another function. This is how you build reusable, parameterized behavior without inheritance, builders, or configuration-heavy factories.

The returned function often “closes over” values from the outer scope (a closure), which lets you customize behavior once and then apply it many times.

Common uses

  • Specialize a general function with a fixed parameter (partial is the built-in helper).
  • Build small validators, parsers, or adapters for interop boundaries.
  • Create composable middleware-like behavior.

Java mental model: this is like returning a lambda that captures some variables, but it is idiomatic and lightweight in everyday Clojure.

This section focuses on writing these patterns clearly so future readers do not have to mentally debug a maze of anonymous functions.

In this section

Revised on Friday, April 24, 2026