I am trying to write a multi-method which dispatches based on the types of all the arguments passed to it, but I am struggling to figure out how to write such a distpatch fn.
By that I mean, given:
(defmulti foo (fn [& args] ...)) (defmethod foo String [& args] (println "All strings")) (defmethod foo Long [& args] (println "All longs")) (defmethod foo Number [& args] (println "All numbers")) (defmethod foo :default [& args] (println "Default")) Then we would get:
(foo "foo" "bar" "baz") => "All strings" (foo 10 20 30) => "All longs" (foo 0.5 10 2/3) => "All numbers" (foo "foo" 10 #{:a 1 :b 2}) => "Default"
Numbercomplicates things because now you're looking for common super types. Is it actually needed?