Skip to content

Instantly share code, notes, and snippets.

@cgrand
Created March 22, 2010 18:46
Show Gist options
  • Save cgrand/340375 to your computer and use it in GitHub Desktop.
Save cgrand/340375 to your computer and use it in GitHub Desktop.
(defmacro ensure-node [nodes parent-selector tag transform-fn]
`(ensure-node* nodes (selector ~parent-selector) (selector [:> ~tag]) tag transform-fn))
(defn ensure-node* [nodes parent-selector child-selector tag transform-fn]
(transform nodes parent-selector
(fn [elt] (let [content (:content elt)
content* (transform content child-selector transform-fn)]
(if (= content content*) ;; hmm no it would be better to use zip-select
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment