Created
February 17, 2014 13:48
-
-
Save jaycfields/9050825 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
(defmulti nan->keyword class :default :default) | |
(defmethod nan->keyword java.util.Map [m] | |
(if (instance? clojure.lang.IRecord m) | |
(nan->keyword (into {} (seq m))) | |
(let [f (fn [[k v]] [k (if (and (number? v) (Double/isNaN v)) :DoubleNaN v)])] | |
(expectations.clojure.walk/postwalk (fn [x] (if (map? x) (into {} (map f x)) x)) m)))) | |
(defmethod nan->keyword java.util.List [m] | |
(map #(if (and (number? %) (Double/isNaN %)) :DoubleNaN %) m)) | |
(defmethod nan->keyword Double [m] | |
(if (Double/isNaN m) :DoubleNaN m)) | |
(defmethod nan->keyword java.util.Set [m] | |
(reduce #(conj %1 (if (and (number? %2) (Double/isNaN %2)) :DoubleNaN %2)) #{} m)) | |
(defmethod nan->keyword :default [m] | |
(if (and (number? m) (Double/isNaN m)) :DoubleNaN m)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment