-
-
Save ELLIOTTCABLE/441059 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
(defclass rock ()()) | |
(defclass paper ()()) | |
(defclass scissors ()()) | |
(defgeneric r-p-s (a b)) | |
(defmethod r-p-s ((r rock) (p paper)) 'paper) | |
(defmethod r-p-s ((r rock) (s scissors)) 'rock) | |
(defmethod r-p-s ((p paper) (s scissors)) 'scissors) |
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
rock ← list clone() | |
paper ← list clone() | |
scissors ← list clone() | |
(rock, paper) compete ← routine | |
result(`select { @isa paper }) | |
(paper, scissors) compete ← routine | |
result(`select { @isa scissors }) | |
(scissors, rock) compete ← routine | |
result(`select { @isa rock }) | |
“--- Usage:” | |
john’s ← rock clone() | |
bob’s ← paper clone() | |
(john’s, bob’s) compete() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment