Created
June 4, 2020 16:28
-
-
Save jdkealy/f0923bcd4312c692e4fc41f5864636ce to your computer and use it in GitHub Desktop.
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
(defn rect [wd ht] {:Shape ::rect :wd wd :ht ht}) | |
(defn circle [radius] {:Shape ::circle :radius radius}) | |
(defn square [wd ht ] {:Shape ::square :wd wd :ht ht}) | |
(defmethod area :default [x] :oops) | |
(defmethod area ::rect [r] | |
(* (:wd r) (:ht r))) | |
(derive ::square ::rect) | |
(area (rect 10 10)) | |
(area (square 10 10)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment