clojure.pprint 似乎做我想做的事:
user=> (def a {"q" {:q 1 :w 2 :e 3 :r 4 :t 4}, "w" {:q 1 :w 2 :e 3 :r 4 :t 4} "e" {:q 1 :w 2 :e 3 :r 4 :t 4}, "r" {:q 1 :w 2 :e 3 :r 4 :t 4}})
user=> (pprint a)
{"e" {:r 4, :e 3, :w 2, :t 4, :q 1},
"q" {:r 4, :e 3, :w 2, :t 4, :q 1},
"r" {:r 4, :e 3, :w 2, :t 4, :q 1},
"w" {:r 4, :e 3, :w 2, :t 4, :q 1}}
nil
但
user=> (time (with-out-str (pprint a)))
"Elapsed time: 174.621945 msecs"
...
user=> (time (do (with-out-str (pprint (repeat 1000 {:r 4 :t 6 :q 3 :u 5 :d 3}))) nil))
"Elapsed time: 32902.028436 msecs"
它太慢了。
Clojure 中是否有任何打印机可以进行缩进(可能不如 pprint 准确),但速度也很快并且适用于大型结构?