Created
January 20, 2017 16:32
-
-
Save jmorton/068a56fc41d5e3ed7c8af0619100e8fe to your computer and use it in GitHub Desktop.
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
(defmulti numberize (fn [n] (type n))) | |
(defmethod numberize :default [n] | |
':clojure.spec/invalid) | |
(defmethod numberize Number [number] | |
number) | |
(defmethod numberize String [string] | |
(let [number-format (java.text.NumberFormat/getInstance)] | |
(try | |
(.parse number-format string) | |
(catch java.text.ParseException ex | |
:clojure.spec/invalid)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment