Created
December 3, 2010 09:39
-
-
Save sunilnandihalli/726773 to your computer and use it in GitHub Desktop.
more idiomatic clojure ..
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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