(defmethod p-position (value (list persistent-cons)
&key (key #'identity) (test #'p-eql)
(start 0) (end nil))
;; Move list to start position.
(loop repeat start
do (setq list (p-cdr list)))
;; The real work.
(loop for i from start do
(if (or (p-endp list) (and end (= i end)))
(return-from p-position nil)
(let ((elt (funcall key (p-car list))))
(if (funcall test value elt)
(return-from p-position i)
(setq list (p-cdr list))))))
;; Return nil if not found.
nil)
Source Context