Skip to content

Instantly share code, notes, and snippets.

@shark8me
Created February 23, 2013 08:42
Show Gist options
  • Select an option

  • Save shark8me/5018993 to your computer and use it in GitHub Desktop.

Select an option

Save shark8me/5018993 to your computer and use it in GitHub Desktop.
;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