Skip to main content

Persistent Data Structures

intermediate

What Are Persistent Data Structures?

Persistent data structures preserve previous versions of themselves when modified. Instead of changing in place, operations return a new version while the old version remains available.

Structural Sharing

Clojure's persistent data structures use structural sharing to make immutability efficient. When you "modify" a vector, the new vector shares most of its structure with the original.

Why It Matters

This design gives you the safety of immutability with near-constant-time performance for most operations.