I have some code that uses multi-methods and would ideally like to overload the function (in this case, multi-function) so that I can pass in a higher order function to help wit
Basically you can dispatch on anything, neither the type nor the number of args has to be consistent..like this:
(defn- map-classes [an-object]
(let [cmap
{1 :thing
2 666
3 "yada"}
the-class (class an-object)]
(get cmap an-object the-class)))
(defn- mk-class [& args] (map #(map-classes %) args))
(defmulti play-thing mk-class )
(defmethod play-thing [:thing] [v] (= 1 v))
(defmethod play-thing [666] [v] (= 2 v))
(defmethod play-thing ["yada" String] [v x] (str x v))
The possibilities are endless