Last active
October 26, 2024 14:22
-
-
Save Vadym-Lopatka/88744eff093514b67b9e04fbb18bf01e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| (defmulti encounter (fn [x y] [(:Species x) (:Species y)])) | |
| (defmethod encounter [:Bunny :Lion] [b l] :run-away) | |
| (defmethod encounter [:Lion :Bunny] [l b] :eat) | |
| (defmethod encounter [:Lion :Lion] [l1 l2] :fight) | |
| (defmethod encounter [:Bunny :Bunny] [b1 b2] :mate) | |
| (def b1 {:Species :Bunny :other :stuff}) | |
| (def b2 {:Species :Bunny :other :stuff}) | |
| (def l1 {:Species :Lion :other :stuff}) | |
| (def l2 {:Species :Lion :other :stuff}) | |
| (encounter b1 b2) ;: :mate | |
| (encounter b1 l1) ;: :run-away | |
| (encounter l1 b1) ;: :eat | |
| (encounter l1 l2) ;: :fight |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment