(defun positions-1 (item list)
    (loop for element in list
          for index from 0
          when (equalp item element) collect index))

(defun positions-2 (item list &optional positions (index 0))
    (cond
        ((endp list) (nreverse positions))
        ((equalp item (car list))
         (positions-2 item (cdr list) (cons index positions) (1+ index)))
        (t (positions-2 item (cdr list) positions (1+ index)))))
Edit
Pub: 10 Jul 2019 21:59 UTC
Edit: 10 Jul 2019 22:02 UTC
Views: 344