Skip to content

Instantly share code, notes, and snippets.

@vorg
Created April 2, 2014 11:25
Show Gist options
  • Save vorg/9932300 to your computer and use it in GitHub Desktop.
Save vorg/9932300 to your computer and use it in GitHub Desktop.
ClojureScript hasmaps magic
;;make some complex hashmap with numbers, edges and complex structs
(def c {:from 0 :to 1 [0, 1] 3 #{0 {:x 2 :y 3} 1 {:x 0 :y 3}} 4})
;;test getting edge value
(get c #{0 {:x 2 :y 3} 1 {:x 0 :y 3}})
;;define points
(def p1 {:x 2 :y 3})
(def p2 {:x 0 :y 3})
;;define new edge with the same values
(def edge #{ 0 p1 1 p2})
;;test -> it works!! why?
(get c edge)
;;test with another hash map that has the same values -> it works OMG! WHY?
(def edge2 #{ 0 p1 1 {:x 0 :y 3}})
(get c edge2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment