Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在 Lisp 中,我如何找到一个列表有多少个不同的元素?
(length (remove-duplicates <your list>))
最短的方法,但也可以一次性完成,如下所示:
(defun count-distinct (list) (let ((table (make-hash-table))) (dolist (i list (hash-table-count table)) (setf (gethash i table) t))))