Are pattern matching or polymorphic dispatch available as a conditional structures in clojure?
clojure
Solution
You want to use multimethods. This is an excellent article explaining you how to use those. http://adambard.com/blog/structured-clojure-protocols-and-multimethods/
(def speed 24)
(defmulti get-speed :type)
(defmethod get-speed :european [_] speed)
(defmethod get-speed :african [_] (+ speed 2))
(defmethod get-speed :norwegian-blue [_] (* speed 1.05))
(get-speed {:type :european})
; => 200
Problem
In a static language, I can replace conditional with polymorphism. In languages like erlang I can use pattern matching instead of if else. What can I use in clojure?