Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (defn gen-id-dispatch
- [& args]
- (let [n (count args)]
- (cond
- (= n 1) (class (first args))
- (= n 2) :pair
- :else nil)))
- (defmulti gen-id #'gen-id-dispatch :default nil)
- (defmethod gen-id :pair
- [x y]
- {:a x :b y})
- (defmethod gen-id String
- [x]
- {:a 0 :b x})
- (defmethod gen-id nil [x] nil)
Add Comment
Please, Sign In to add comment