A pretty-printer for Clojure data structures.
Based on the algorithm described in "Pretty-Printing, Converting List to Linear Structure" by Ira Goldstein (Artificial Intelligence, Memo No. 279 in Massachusetts Institute of Technology A.I. Laboratory, February 1973).
Here's how the algorithm (as implemented in this namespace) works: given a form, if there is enough space remaining on the current line to print the entire form without any line breaks, do so. We call this style of printing the "linear" style. The printing functions (prn et al.) in clojure.core always print in the linear style.
If there is not enough room to print in the linear style, print the form in "miser" style instead. In the miser style, we insert a line break after each form (except map keys, if there is enough room to fit the entire value on the same line), and indent each form according to the current nesting level.
A pretty-printer for Clojure data structures. Based on the algorithm described in "Pretty-Printing, Converting List to Linear Structure" by Ira Goldstein (Artificial Intelligence, Memo No. 279 in Massachusetts Institute of Technology A.I. Laboratory, February 1973). Here's how the algorithm (as implemented in this namespace) works: given a form, if there is enough space remaining on the current line to print the entire form without any line breaks, do so. We call this style of printing the "linear" style. The printing functions (prn et al.) in clojure.core always print in the linear style. If there is not enough room to print in the linear style, print the form in "miser" style instead. In the miser style, we insert a line break after each form (except map keys, if there is enough room to fit the entire value on the same line), and indent each form according to the current nesting level.
(pprint x)
(pprint x opts)
(pprint writer x {:keys [max-width] :or {max-width 72} :as opts})
Pretty-print an object.
Given one arg (an object), pretty-print the object into out using the default options.
Given two args (an object and an options map), pretty-print the object into out using the given options.
Given three args (a java.io.Writer, a object, and an options map), pretty-print the object into the writer using the given options.
If print-dup is true, pprint does not attempt to pretty-print; instead, it falls back to default print-dup behavior.
Options:
:max-width (long or ##Inf, default: 72) Avoid printing anything beyond the column indicated by this value.
Pretty-print an object. Given one arg (an object), pretty-print the object into *out* using the default options. Given two args (an object and an options map), pretty-print the object into *out* using the given options. Given three args (a java.io.Writer, a object, and an options map), pretty-print the object into the writer using the given options. If *print-dup* is true, pprint does not attempt to pretty-print; instead, it falls back to default print-dup behavior. Options: :max-width (long or ##Inf, default: 72) Avoid printing anything beyond the column indicated by this value.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close