liveBook · Manning

*print-length*

As explained in Clojure: The Essential Reference

*print-length* is a Clojure dynamic variable specifying the maximum number of collection items to print.

*print-length* is a Clojure dynamic variable that limits how many items from each collection printing operation displays. Binding it to 3 shows only the first three items; omitted items appear as an ellipsis. section 23.20

Limit a large nested value

(binding [*print-length* 3] (pprint document)) ;; {:tag :rss, ;; :attrs {:xmlns:media "...", :version "2.0", ...}, ;; :content [{:tag :channel, ...}]} The binding keeps diagnostic output readable while preserving the collection's visible shape.

Use *print-length* with *print-level* when both breadth and nesting must be constrained: the former truncates collection items, while the latter truncates nested collection levels. section 23.20

How Clojure: The Essential Reference covers it

How deep it goes
Defines collection-item truncation and demonstrates local bindings, but defers broader printing internals.
Examples
Uses a parsed BBC RSS XML document printed with a three-item limit, with optional nesting control.
What it assumes
Assumes familiarity with Clojure collections, dynamic variables, binding, and pprint.
What you can do after
Operate/configure printing with binding to constrain collection output during inspection.
How it connects
Connects dynamic variables, pretty printing, *print-level*, binding, and pprint.

Related concepts

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