Skip to content

Instantly share code, notes, and snippets.

@sunilnandihalli
Created December 3, 2010 09:39
Show Gist options
  • Save sunilnandihalli/726773 to your computer and use it in GitHub Desktop.
Save sunilnandihalli/726773 to your computer and use it in GitHub Desktop.
more idiomatic clojure ..
(let [mp (atom {})
d [#{#{1 2}
#{3 4}} ;node1
#{#{5 6}
#{7 8}}]] ;node2
(dorun (for [nd d
nd-pair nd
face nd-pair]
(swap! mp update-in [face] #(conj % nd))))
@mp)
; if you consider that points 1 2 3 4 form the node node1 and 5 6 7 8 form node2
;I would like a map in the opposite direction ..
;i.e. I should be able to find out all the nodes of which 1 is part of and
;that is what the above code is doing.. but would like to know as to what
;would be a more idiomatic way of doing this.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment