*print-base* is a dynamic variable that selects the numeric base used when numbers are printed. Numbers use base 10 by default; temporarily bind another base when a binary or hexadecimal representation is more useful. section 23.20
Printing in binary and hexadecimal
(require '[clojure.pprint :as pprint]) (binding [pprint/*print-base* 2] (pprint/pprint 500)) ;; 111110100 (binding [pprint/*print-base* 16] (pprint/pprint 3405691582)) ;; cafebabe (binding [pprint/*print-base* 16 pprint/*print-radix* true] (pprint/pprint 3405691582)) ;; #xcafebabe section 23.20
Table 23.1. The dynamic variables related to pretty printing
| Name |
Namespace |
Default |
Description |
|
|
|
true |
Print escape sequences literally. |
|
|
|
false |
Print objects so they can be read back into memory. |
|
|
|
nil |
Number of items to print in a collection. |
|
|
|
nil |
Number of nesting collections level to print. |
|
|
|
false |
Should metadata be printed as part of the object. |
|
|
|
true |
Enable/disable pretty printing. |
|
|
|
fn |
Set pretty printer dispatch function. |
|
|
|
72 |
Number of columns to use before breaking into a newline. |
|
|
|
40 |
The column at which to enter miser style. |
|
|
|
nil |
Remove namespace qualifier from symbols. |
|
|
|
nil |
Print radix used for integers or ratio. |
|
|
|
10 |
Change base for printing integers or ratio. |
Compare *print-base* with related printing controls, including *print-radix*, which adds base specifiers for binary, octal, and hexadecimal output. section 23.20
