Skip to content

Instantly share code, notes, and snippets.

@nlacasse
Created January 25, 2013 00:09
Show Gist options
  • Save nlacasse/4630019 to your computer and use it in GitHub Desktop.
Save nlacasse/4630019 to your computer and use it in GitHub Desktop.
insert-resource-node
(defn insert-resource-node!
[inserter res]
(if-let [id (get @id-map res)]
; If the resource has aleady been added, just return the id.
id
; Otherwise, add the node for the node, and remember its id for later.
(let [id (.createNode inserter {"resource" res})]
(swap! id-map #(assoc! % res id))
id)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment