i found example that i can do
(defmethod x 5 [y] (do stuff))
but can i do
(defmethod #( % 10) [y] (do stuff)) somehow? like in a pattern match of
haskell/scala?
--
--
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to
you need a dispatch functions that produces discrete dispatch values
using your example:
(defmulti x #(cond
( % 10) :less-than-10
;;... further conditions producing different dispatch
values
))
;; dispatch on the dispatch values
(defmethod x :less-then-10 [x]
i see
thx
2013/6/23 László Török ltoro...@gmail.com
you need a dispatch functions that produces discrete dispatch values
using your example:
(defmulti x #(cond
( % 10) :less-than-10
;;... further conditions producing different dispatch
values
))
;;