hash
(hash o)
Source docstring:
Returns the hash code of its argument. Note this is the hash code
consistent with =.
(defn hash
[o]
(cond
(implements? IHash o)
(bit-xor (-hash o) 0)
(number? o)
(if ^boolean (js/isFinite o)
(if-not ^boolean (.isSafeInteger js/Number o)
(hash-double o)
(js-mod (Math/floor o) 2147483647))
(case o
##Inf
2146435072
##-Inf
-1048576
2146959360))
;; note: mirrors Clojure's behavior on the JVM, where the hashCode is
;; 1231 for true and 1237 for false
;; http://docs.oracle.com/javase/7/docs/api/java/lang/Boolean.html#hashCode%28%29
(true? o) 1231
(false? o) 1237
(string? o)
(m3-hash-int (hash-string o))
(instance? js/Date o)
(bit-xor (.valueOf o) 0)
(nil? o) 0
:else
(bit-xor (-hash o) 0)))