| Paste number 24115: | ow ow ow |
| Pasted by: | Xof |
| When: | 2 years, 10 months ago |
| Share: | Tweet this! | http://paste.lisp.org/+ILV |
| Channel: | #lisp |
| Paste contents: |
(defclass listoid ()
((caroid :initarg :caroid)
(cdroid :initarg :cdroid :initform nil)))
(defmethod lengthoid ((x listoid))
(let ((result 0))
(loop until (null x)
do (incf result) (setq x (slot-value x 'cdroid)))
result))
(assert (= (lengthoid (make-instance 'listoid)) 1))
(assert (= (lengthoid (make-instance 'listoid :cdroid
(make-instance 'listoid :cdroid
(make-instance 'listoid))))
3))
This paste has no annotations.