<?xml version="1.0"?>
<paste-with-annotations>
  <paste>
    <number>
      <integer>18224</integer>
    </number>
    <user>
      <string>sneakin</string>
    </user>
    <title>
      <string>eqv</string>
    </title>
    <contents>
      <string>;;; The following equivalence checker was created by Nolan Eakins,
;;; http://nolan.eakins.net/ . This code can be treated as if it's
;;; public domain or public domain plus an attribution. This requires
;;; Gary King's Moputilities.

(defgeneric eqv (a b)
  (:documentation &quot;This method is used to compare classes. Override it
to specialize it's testing for your classes. There's already a method
specialized for built in classes that uses EQUAL, cons cells, and any
standard object.&quot;))

(defmethod eqv (a b)
  (equal a b))

(defmethod eqv ((a cons) (b cons))
  (cond
    ((and a b)
     (and (eqv (first a) (first b))
	  (eqv (rest a) (rest b))))
    (t
     nil)))

(defun and-list (list)
  (if list
    (and (first list)
	 (and-list (rest list)))
    t))

(defmethod eqv ((a standard-object) (b standard-object))
  (when (eq (type-of a) (type-of b))
    (and-list
     (mapcar #'(lambda (slot)
		 (eqv (slot-value a slot)
		      (slot-value b slot)))
	     (mopu:slot-names (find-class (type-of a)))))))</string>
    </contents>
    <universal-time>
      <integer>3352158219</integer>
    </universal-time>
    <channel>
      <string>#lisp</string>
    </channel>
    <colorization-mode>
      <string>Basic Lisp</string>
    </colorization-mode>
    <maybe-spam>
      <null/>
    </maybe-spam>
    <is-unicode>
      <null/>
    </is-unicode>
  </paste>
  <annotation>
    <number>
      <integer>1</integer>
    </number>
    <user>
      <string>sneakin</string>
    </user>
    <title>
      <string>Correction</string>
    </title>
    <contents>
      <string>This requires Gary King's Moptilities.</string>
    </contents>
    <universal-time>
      <integer>3352159652</integer>
    </universal-time>
    <channel>
      <string>#lisp</string>
    </channel>
    <colorization-mode>
      <string></string>
    </colorization-mode>
    <maybe-spam>
      <null/>
    </maybe-spam>
    <is-unicode>
      <null/>
    </is-unicode>
  </annotation>
</paste-with-annotations>