On Sat, Oct 23, 2010 at 5:16 PM, Paul Richards <paul.richa...@gmail.com> wrote: > Hi, > I have a multimethod which is dispatched on two arguments: > > (defmulti bar (fn [x y] [x y])) > (defmethod bar [1 2] ..) > (defmethod bar [3 4] ..) > > Is there a way I can define methods on this which use "wildcards"?
What about something like: (defmulti bar (fn [x y] [(if (= y 16) :any x) (if (= x 42) :any y)]) (defmethod bar [42 :any] [x y] ...) (defmethod bar [:any 16] [x y] ...) (defmethod bar [:any :any] [x y] ...) (defmethod bar :default [x y] ...) The function is a little less pretty, but it does the job. The only trick is that (bar 42 16) comes back as the [:any :any] case, but you could always let that fall through to the default. Regards, Paul -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en