Hello,

I have a situation in which different multi-methods
need similar behavior with different arguments.

So they call the same function (one-or-two below)
with the arguments. E.g.

    (defmulti what-num (fn [x] x))

    (defn one-or-two [x] (println "saw one or two: " x))

    (defmethod what-num :one [x] (one-or-two x))
    (defmethod what-num :two [x] (one-or-two x))
    (defmethod what-num :three [x] (println "saw 3"))
    (defmethod what-num :four [x] (println "saw 4"))

    user=> (what-num :one)
    saw one or two:  :one
    nil
    user=> (what-num :two)
    saw one or two:  :two
    nil
    user=> (what-num :three)
    saw 3

This works fine. However, I was wondering if its at all
possible to return duplication of creating the
methods 'what-num :one [x]' and 'what-num :two [x]'.

Can we have something to the effect of
'what-num (or :one :two) [x]'? This would help get
rid of one-or-two and I would be able to define a single
what-num for this.

I could have 'defmulti what-num' conditionally return
something like :one-or-two but I am not sure if thats such
a good idea as I might end up with a big 'cond' over
time.

What would be a good way to do something like this?

Thanks.
Parth

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to