Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (defun occurrences (lst)
- (let* ((elements (remove-duplicates lst))
- (alist (pairlis elements (make-list (length elements) :initial-element 0))))
- (loop for x in lst
- do (incf (cdr (assoc x alist))))
- alist))
- (defun o(lst)
- (let ((table (make-hash-table)))
- (loop for x in lst
- do (incf (gethash x table 0)))
- (loop for k being the hash-key of table
- using (hash-value v)
- collect (cons k v))))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement