Skip to content

Instantly share code, notes, and snippets.

@akhileshs
Last active August 29, 2015 14:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save akhileshs/cc2c982b503fad05074d to your computer and use it in GitHub Desktop.
Save akhileshs/cc2c982b503fad05074d to your computer and use it in GitHub Desktop.
basic bst
user=> (defrecord TreeNode [val l r])
user.TreeNode
user=> (TreeNode. 5 nil nil)
#user.TreeNode{:val 5, :l nil, :r nil}
user=> (defn xconj [t v]
#_=> (cond
#_=> (nil? t) (TreeNode. v nil nil)
#_=> (< v (:val t)) (TreeNode. (:val t) (xconj (:l t) v) (:r t))
#_=> :else (TreeNode. (:val t) (:l t) (xconj (:r t) v))))
#'user/xconj
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment