Clojure Cheat Sheet
A compact reference for Clojure syntax, core functions, and JVM-friendly idioms.
Use this appendix as a “quick look” reference while you work through the main chapters. It is intentionally compact: enough to remind you of the shape of common forms without turning into a second textbook.
If you are coming from Java, the most valuable parts are usually the syntax reference and the core collection operations. When you feel stuck translating an imperative loop, check the cheat sheet and try expressing the same logic as a small transformation pipeline in the REPL.
In this section
-
Syntax Reference
A quick refresher on reader syntax, literals, namespaces, and the special forms you must recognize.
-
Basic Syntax and Data Types
How to read Clojure forms and the literals you’ll see most: numbers, strings, keywords, symbols, and nil.
-
Collection Literals
Quick reference for Clojure collection literals and the operations you’ll use most on lists, vectors, maps, and sets.
-
Functions and Anonymous Functions
How to define and use functions in Clojure: arities, anonymous functions, variadic args, destructuring, and apply.
-
Special Forms and Macros
Recognize the small set of special forms and understand what macros do when reading real Clojure code.
-
Namespaces and Imports
How to declare a namespace, require Clojure libraries, and import Java classes in an idiomatic ns form.
-
Common Functions and Macros
The core toolbox for everyday Clojure: mapping/filtering/reducing data, threading, and common macros.
-
Sequence Operations
Use map/filter/reduce and friends to build readable data pipelines; most sequence transforms are lazy.
-
Collection Manipulation
The everyday update operations for persistent collections: get/assoc/update/conj plus dissoc/disj/into and nested helpers.
-
Function Composition and Utilities
Build functions from functions with comp/partial/juxt plus apply and memoize for practical pipelines.
-
Threading Macros
Make transformation pipelines readable with ->, ->>, and the conditional threading variants some-> and cond->.
-
Conditional Macros
Everyday branching tools beyond if: when, if-let/when-let, cond, and case (plus the truthiness rules that matter).
-
Data Structures Overview
Persistent collections in one place: vectors, lists, maps, and sets—plus the operations you’ll use most.
-
Lists
When to use Clojure’s immutable linked lists (mostly for code and stack-like operations) and how conj/cons/first/rest behave.
-
Vectors
Clojure’s default ordered collection: persistent vectors with fast indexed access, assoc updates, and conj at the end.
-
Maps
Clojure’s go-to “record” type: persistent maps with keyword keys, fast lookup, and immutable assoc/update/merge operations.
-
Sets
Unique collections with fast membership tests: create sets, add/remove items, and use clojure.set for union/intersection/difference.
-
Keywords and Symbols
How keywords and symbols differ: keywords are self-evaluating identifiers (often map keys); symbols resolve to vars/functions.
-
Concurrency Utilities
Quick reference for Clojure’s state and async tools: atoms/refs/agents plus futures/promises and related utilities.
-
Atoms
Atoms are Clojure’s go-to for synchronous, independent state: atomic updates with swap! and reset! (think AtomicReference).
-
Refs and Transactions
Refs use Software Transactional Memory (STM) for coordinated, synchronous updates to multiple pieces of shared state.
-
Agents
Agents manage asynchronous, independent state changes: queue actions with send/send-off and handle failures explicitly.
-
Futures and Promises
Simple async tools on the JVM: futures run a computation; promises are one-time values you deliver later (both deref with @).
Revised on Friday, April 24, 2026