Printing Clojure's datastructures as graphs using vijual
- Official site: http://lisperati.com/vijual/
- Fixed version for Clojure 1.3: https://github.com/overtone/vijual
cljsta.graph> (draw-tree [[:north-america [:usa [:miami] [:seattle] [:idao [:boise]]]] [:europe [:germany] [:france [:paris] [:lyon] [:cannes]]]]) +------------+ +--------+ | north | | europe | | america | +---+----+ +-----+------+ | | +---------+---------+ + | | | +----+----+ +---+----+ +--+--+ | germany | | france | | usa | +---------+ +---+----+ +--+--+ | | +--------+---------+ +---------++---------+ | | | | | | +---+---+ +--+---+ +---+----+ +---+---+ +----+----+ +--+---+ | paris | | lyon | | cannes | | miami | | seattle | | idao | +-------+ +------+ +--------+ +-------+ +---------+ +--+---+ | + | +---+---+ | boise | +-------+ nil
Pretty printing tables using Clojure core lib
- No external lib required.
- http://clojuredocs.org/clojure_core/clojure.pprint/print-table
cljsta.graph> (clojure.pprint/print-table [{:a 1 :b 2 :c 3} {:b 5 :a 7 :c "dog"}]) ============= :a | :c | :b ============= 1 | 3 | 2 7 | dog | 5 ============= nil
Pretty printing tables using cldwalker / table
cljsta.graph> (table (meta #'doc)) +-----------+---------------------------------------------------------------+ | key | value | +-----------+---------------------------------------------------------------+ | :macro | true | | :ns | clojure.repl | | :name | doc | | :arglists | ([name]) | | :added | 1.0 | | :doc | Prints documentation for a var or special form given its name | | :line | 120 | | :file | clojure/repl.clj | +-----------+---------------------------------------------------------------+ nil
Pretty printing tables using joegallo / doric
https://github.com/joegallo/doriccljsta.lib-example.joegallo-table> (println (table [{:a 1 :b 2}])) |---+---| | A | B | |---+---| | 1 | 2 | |---+---| nil
It even have barcharts! (I love this one):
cljsta.lib-example.joegallo-table> (defn trunc [x] (double (/ (int (* 100 x)) 100))) #'cljsta.lib-example.joegallo-table/trunc cljsta.lib-example.joegallo-table> (defn gauss [x] (/ (Math/exp (- (* 1/2 x x))) (Math/sqrt (* 2 Math/PI))) ) #'cljsta.lib-example.joegallo-table/gauss cljsta.lib-example.joegallo-table> (println (table ^{:format raw} [:x {:name :y :format bar}] (map (fn [x] {:x (trunc x) :y (int (* 80 (gauss x)))}) (range -2.8 2.8 0.15)) )) X Y -2.8 -2.65 -2.5 # -2.35 ## -2.2 ## -2.05 ### -1.9 ##### -1.75 ###### -1.6 ######## -1.45 ########### -1.3 ############# -1.15 ################ -1.0 ################### -0.85 ###################### -0.7 ######################## -0.55 ########################### -0.4 ############################# -0.25 ############################## -0.1 ############################### 0.04 ############################### 0.19 ############################### 0.34 ############################## 0.49 ############################ 0.64 ######################### 0.79 ####################### 0.94 #################### 1.09 ################# 1.24 ############## 1.39 ########### 1.54 ######### 1.69 ####### 1.84 ##### 1.99 #### 2.14 ### 2.29 ## 2.44 # 2.59 # 2.74 nil