Skip to content

Instantly share code, notes, and snippets.

@RobinRamael
Created January 19, 2011 18:48
Show Gist options
  • Save RobinRamael/786623 to your computer and use it in GitHub Desktop.
Save RobinRamael/786623 to your computer and use it in GitHub Desktop.
find the classcastexception...
(defn semi-splay [tree el]
(loop [nds tree x el]
(let [to-splay (take 3 (get-path nds x))]
(if (> (count to-splay) 2)
(let [outer-trees (get-outer-trees to-splay)
sorted-to-splay (sort-by-vals to-splay)
new-root (:val (second sorted-to-splay))]
(recur (swap-nodes
nds (:val (last to-splay))
{:val new-root
:left {:val (:val (first sorted-to-splay))
:left (first outer-trees)
:right (second outer-trees)}
:right {:val (:val (third (sorted-to-splay)))
:left (third outer-trees)
:right (last outer-trees)}
})
new-root))
nds))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment