Last active
January 5, 2022 23:34
-
-
Save bollu/023dc09a50d06b05e0967091ba2f99c9 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
;; equivalent upto structure | |
(defgeneric deepeq (x y)) | |
(defmethod deepeq ((x number) y) | |
(equal x y)) | |
(defmethod deepeq ((x symbol) y) | |
(equal x y)) | |
(defmethod deepeq (x y) | |
(if (equal (class-of x) (class-of y)) | |
(let* ((cls (class-of x)) ;; then | |
(allslots (class-direct-slots cls))) | |
(reduce (lambda (out slot) | |
(let* | |
((name (slot-definition-name slot)) | |
(xval (slot-value x name)) | |
(yval (slot-value y name))) | |
(and out (deepeq xval yval)))) | |
allslots :initial-value t)) | |
nil ;; else | |
)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment