Created
February 23, 2013 08:42
-
-
Save shark8me/5018993 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
| ;adds 2 children to a leaf node | |
| (defn add-children [{x :self :as m}] | |
| (assoc m :cren [ {:self (inc x)} {:self (dec x)}])) | |
| (def xroot {:self 20 :cren [ | |
| {:self 10 } | |
| {:self 30 } | |
| ]}) | |
| ;the nodes 10 and 30 now have 2 children: 11,9 and 31,29 | |
| (is (= '(11 9 31 29) | |
| (map :self (map zip/node | |
| (-> (leaf-grown add-children (mzipper xroot)) mzipper leafnodes))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment