Skip to content

Instantly share code, notes, and snippets.

@brianium
Created June 22, 2016 01:09
Show Gist options
  • Save brianium/41504b7266ae27c8491d51c00fd3c85a to your computer and use it in GitHub Desktop.
Save brianium/41504b7266ae27c8491d51c00fd3c85a to your computer and use it in GitHub Desktop.
(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