Skip to content

Instantly share code, notes, and snippets.

@swannodette
Created July 19, 2011 03:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save swannodette/1091247 to your computer and use it in GitHub Desktop.
Save swannodette/1091247 to your computer and use it in GitHub Desktop.
multi.clj
(defmulti foo (fn [x y] (into #{} [x y])))
(defmethod foo #{::a ::b}
[x y] "We found ::a ::b")
(defmethod foo #{::c ::d}
[x y] "We found ::c ::d")
(comment
(foo ::b ::a) ;; "We found ::a ::b"
(foo ::d ::c) ;; "We found ::c ::d"
)
(defmulti bar (fn [x y] [x y]))
(defmethod bar [::car ::car]
[x y] "2 cars")
(derive ::porsche ::car)
(derive ::delorean ::car)
(comment
(bar ::porsche ::delorean) ;; "2 cars"
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment