Created
November 3, 2020 00:58
-
-
Save justinmeiners/a9bf4ada2d43b724396a1f6e3ea3b734 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun compact-duplicates (vector cmp) | |
(prog ((i 1) | |
(j 1) | |
(N (length vector)) | |
(x (aref vector 0))) | |
loop | |
(if (not (funcall cmp (aref vector i) x)) | |
(progn | |
(setf x (aref vector i)) | |
(setf (aref vector j) x) | |
(incf j) | |
)) | |
(incf i) | |
(if (< i N) | |
(go loop) | |
) | |
(return (subseq vector 0 j)) | |
)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment