Created
April 17, 2012 03:48
-
-
Save espeed/2403336 to your computer and use it in GitHub Desktop.
Multimethod Not Working
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; Trying to use type hinting to differentiate between two single-arg methods, | |
;; but I suspect I'm doing it totally wrong | |
(defmulti add-vertex (fn [& args] (map class args))) | |
(defmethod add-vertex [] (add-vertex nil nil)) | |
(defmethod add-vertex Integer [id] (add-vertex id nil)) | |
(defmethod add-vertex Map [props] (add-vertex nil props)) | |
(defmethod add-vertex [Integer Map] [id props] | |
((let [vertex (. *g* addVertex id)] | |
(when props | |
(apply set-property! vertex (interleave (map name (keys props)) (vals props)))) | |
vertex))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment