
3 Sep
2004
3 Sep
'04
7:04 p.m.
;;; Haven't we all felt the need to sanitize your sequences and making each ;;; element "unique"? I haven't, but I had some spare minutes waiting for ;;; a friend over lunch and since I'd been running the unix command uniq(1) ;;; and been irritated at its shortcomings, this came to be: (defun unique (data &key (test #'eql) (key #'identity)) (let ((acc nil) (type (typecase data (vector 'vector) (string 'string) (list 'list)))) (flet ((frob (data) (unless (member (funcall key data) acc :test test :key key) (push data acc)))) (map nil #'frob data)) (coerce (nreverse acc) type)))