Skip to content

Instantly share code, notes, and snippets.

View jhannes's full-sized avatar

Johannes Brodwall jhannes

View GitHub Profile
@jhannes
jhannes / print-tree.clj
Created April 29, 2011 10:22
Tree pretty printer in clojure
(defn print-subtree [subtree prefix]
(if (empty? subtree)
""
(apply str prefix (first subtree) "\n"
(map #(print-subtree %1 (str "\t" prefix)) (rest subtree)))))
(defn print-tree [tree]
(print-subtree tree ""))
(deftest print-empty-tree