-
-
Save viksit/429567 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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