Skip to content

Instantly share code, notes, and snippets.

@bollu
Last active January 5, 2022 23:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bollu/023dc09a50d06b05e0967091ba2f99c9 to your computer and use it in GitHub Desktop.
Save bollu/023dc09a50d06b05e0967091ba2f99c9 to your computer and use it in GitHub Desktop.
;; 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