Created
June 22, 2016 01:09
-
-
Save brianium/41504b7266ae27c8491d51c00fd3c85a to your computer and use it in GitHub Desktop.
This file contains hidden or 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
(defprotocol FIXO | |
(fixo-push [fixo value]) | |
(fixo-pop [fixo]) | |
(fixo-peek [fixo])) | |
(extend-type TreeNode | |
FIXO | |
(fixo-push [node value] | |
(xconj node value)) | |
(fixo-peek [node] | |
(if (:l node) | |
(recur (:l node)) | |
(:val node))) | |
(fixo-pop [node] | |
(if (:l node) | |
(TreeNode. (:val node) (fixo-pop (:l node)) (:r node)) | |
(:r node)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment