Guest User

Untitled

a guest
Oct 20th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.31 KB | None | 0 0
  1. (defn gen-id-dispatch
  2. [& args]
  3. (let [n (count args)]
  4. (cond
  5. (= n 1) (class (first args))
  6. (= n 2) :pair
  7. :else nil)))
  8.  
  9. (defmulti gen-id #'gen-id-dispatch :default nil)
  10.  
  11. (defmethod gen-id :pair
  12. [x y]
  13. {:a x :b y})
  14.  
  15. (defmethod gen-id String
  16. [x]
  17. {:a 0 :b x})
  18.  
  19. (defmethod gen-id nil [x] nil)
Add Comment
Please, Sign In to add comment