From 42bd8cc5d9629058a97a634ee66214832f937b16 Mon Sep 17 00:00:00 2001 From: jbranchaud Date: Mon, 16 Nov 2015 21:29:09 -0600 Subject: [PATCH] Add Pretty Print The Last Thing as a clojure til. --- README.md | 1 + clojure/pretty-print-the-last-thing.md | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 clojure/pretty-print-the-last-thing.md diff --git a/README.md b/README.md index fa7bcfc..7260e28 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,7 @@ smart people at [Hashrocket](http://hashrocket.com/). - [Evaluate One Liners With lein-exec](clojure/evaluate-one-liners-with-lein-exec.md) - [Expanding Macros](clojure/expanding-macros.md) - [Open JavaDocs](clojure/open-javadocs.md) +- [Pretty Print The Last Thing](clojure/pretty-print-the-last-thing.md) - [Quick Clojure Docs](clojure/quick-clojure-docs.md) - [Reductions](clojure/reductions.md) - [Set Max Heap Size](clojure/set-max-heap-size.md) diff --git a/clojure/pretty-print-the-last-thing.md b/clojure/pretty-print-the-last-thing.md new file mode 100644 index 0000000..dc26803 --- /dev/null +++ b/clojure/pretty-print-the-last-thing.md @@ -0,0 +1,17 @@ +# Pretty Print The Last Thing + +Clojure provides `pp` as a convenience macro for pretty printing the last +thing that was output. If you are playing around with a function in the +repl, trying to get the output just right, `pp` can come in handy. + +```clojure +> (fancy-func) +{:one {:a 1, :b 2, :c 3, :d 4}, :two {:b 2, :c 3, :d 4, :e 5}, :three {:c 3, +:d 4, :e 5, :f 6}, :four {:d 4, :e 5, :f 6, :g 7}} +> (clojure.pprint/pp) +{:one {:a 1, :b 2, :c 3, :d 4}, + :two {:b 2, :c 3, :d 4, :e 5}, + :three {:c 3, :d 4, :e 5, :f 6}, + :four {:d 4, :e 5, :f 6, :g 7}} +nil +```