Created
July 1, 2013 15:27
-
-
Save qerub/5901842 to your computer and use it in GitHub Desktop.
Clojure functions for Java enum ordinals
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
(defn enum-ordinal [^Enum x] | |
(.ordinal x)) | |
(defn enum-cmp [cmp & xs] | |
(apply cmp (map enum-ordinal xs))) | |
(defmacro defenumop [cmp] | |
`(def ~(symbol (str "enum" cmp)) | |
(partial enum-cmp ~cmp))) | |
(defenumop =) | |
(defenumop >) | |
(defenumop <) | |
(defenumop >=) | |
(defenumop <=) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment