Created
February 26, 2011 20:30
-
-
Save rik0/845586 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
(defn tree->seq [tree] | |
(letfn [(tree->seq-aux | |
[stack] | |
(if-let [s (seq stack)] | |
(let [{:keys [value left right]} (first stack)] | |
(lazy-seq | |
(cons value | |
(tree->seq-aux | |
(concat (keep identity [left right]) | |
(rest stack)))))) | |
'()))] | |
(tree->seq-aux [tree]))) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment