Skip to content

Instantly share code, notes, and snippets.

@michalmarczyk
Created June 8, 2010 03:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save michalmarczyk/429563 to your computer and use it in GitHub Desktop.
Save michalmarczyk/429563 to your computer and use it in GitHub Desktop.
(def bt {:left {:value 3}
:value 5
:right {:left {:value 2}
:value :foo
:right {:left {:value :bar}
:value :quux
:right {:value 10}}}})
(loop [bt bt
q (clojure.lang.PersistentQueue/EMPTY)]
(let [{:keys [left right value]} bt]
(if left
(recur left (into q [{:value value} right]))
(do (println value)
(cond right (recur right q)
(empty? q) :done
:else (recur (peek q) (pop q)))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment