Skip to content

Instantly share code, notes, and snippets.

@metametaclass
Created October 11, 2012 20:12
Show Gist options
  • Save metametaclass/3875190 to your computer and use it in GitHub Desktop.
Save metametaclass/3875190 to your computer and use it in GitHub Desktop.
(defn flatten-preprocessed-node
"convert preprocessed tree to linear sequence of items"
[[node-attrs children]]
(let [node-flags (:Flags node-attrs)
is-after (:after node-flags)
node-attrs-1 (update-in node-attrs [:Name] #(or % get-default-node-name))
;node-name (or (:Name node-attrs) get-default-node-name)
flatten-children (mapcat flatten-preprocessed-node children)]
(if is-after ;move node after children in output seq and in :Sort (index-path)
(vec (concat flatten-children [(update-in node-attrs-1 [:Path] conj 9999)]))
(vec (concat [node-attrs-1] flatten-children)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment