Created
January 19, 2011 18:48
-
-
Save RobinRamael/786623 to your computer and use it in GitHub Desktop.
find the classcastexception...
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
(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