I have a defmulti / defmethod group that takes pairs of arguments, for example ...
(defmulti foo "some explanation" (fn [arg1 arg2] (mapv class [arg1 arg2])))
(defmethod foo [N P] (->L 1 2 3))
(defmethod foo [L P] (->N 5))
(defmethod foo [P N] (->L 6 7 8))
...
Which are called as you might expect.
(foo (->N 9) (->P 9))
I would like to call "foo" with more than two arguments. I know how to do this with functions, and I believe that I could use some wrapper function that split the arguments into pairs and then merged the result (or just used the “shorthand”), but that seems wrong.
My question then ... What is the idiomatic way of defining variational multifunction in clojure?
source
share