(defclass generic-list () ( (contents :accessor contents) ) ) (defmethod make-empty ((alist generic-list)) (setf (contents alist) nil) ) (defmethod is-empty ((alist generic-list)) (null (contents alist)) ) (defmethod insert-item ( item (alist generic-list) ) (setf (contents alist) (cons item (contents alist))) ) (defmethod remove-item ((alist generic-list)) (let ( (result (first (contents alist))) ) (setf (contents alist) (rest (contents alist))) result ) ) ;; note: stack would be better in its own file (defclass stack (generic-list) ( ) ) ;; note: queue would be better in its own file (defclass queue (generic-list) ( ) ) (defmethod insert-item ( item (alist queue) ) (setf (contents alist) (append (contents alist) (list item))) ) ;; an example of using the stack class ;; note: my-stack is global (setf my-stack (make-instance 'stack)) (make-empty my-stack) (insert-item 1 my-stack) (insert-item 2 my-stack) (insert-item 3 my-stack) (is-empty my-stack) (remove-item my-stack) (describe my-stack)