> So in this particular case I wouldn't care, but in general I'd expect
> the prefer-method stuff to kick in. :)
Oops, forgot about prefer-method. My noobishness is showing again.
Well, in for a dime in for a dollar. Here's something I whipped up
just for the general amusement of the list. It's not quite what you
asked for, but it might be suitable as a source of ideas, instruction,
derision, or whatever.
(defmulti bar (fn [x y & more] [x y]))
(defmethod bar :default [x y & more]
(if more ; did default loop back to itself?
nil
(some identity [(bar :wild y x)
(bar x :wild y)])))
(defmethod bar [:wild 16] [x-wild y & more]
(let [x (first more)]
(str "First arg wild " x ", " y)))
(defmethod bar [42 :wild] [x y-wild & more]
(let [y (first more)]
(str "Second arg wild " x ", " y)))
(defmethod bar [10 20] [x y]
(pr-str "Plain vanilla args " x ", " y))
user> (bar 10 20)
"\"Plain vanilla args \" 10 \", \" 20"
user> (bar 42 20)
"Second arg wild 42, 20"
user> (bar 10 16)
"First arg wild 10, 16"
user> (bar 42 16)
"First arg wild 42, 16"user> (bar 10 20)
"\"Plain vanilla args \" 10 \", \" 20"
user> (bar 42 20)
"Second arg wild 42, 20"
user> (bar 10 16)
"First arg wild 10, 16"
user> (bar 42 16)
"First arg wild 42, 16"
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en