Skip to content

Instantly share code, notes, and snippets.

@philipschwarz
Created February 3, 2015 23:44
Show Gist options
  • Save philipschwarz/56dd3e822f5565ab1748 to your computer and use it in GitHub Desktop.
Save philipschwarz/56dd3e822f5565ab1748 to your computer and use it in GitHub Desktop.
(defmulti area
"Calculate the area of a shape"
:type)
(defmethod area :rectangle [shape]
(* (:length shape) (:width shape)))
(defmethod area :circle [shape]
(* (. Math PI) (:radius shape) (:radius shape)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment