Skip to content

Instantly share code, notes, and snippets.

@justinmeiners
Created November 3, 2020 00:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save justinmeiners/a9bf4ada2d43b724396a1f6e3ea3b734 to your computer and use it in GitHub Desktop.
Save justinmeiners/a9bf4ada2d43b724396a1f6e3ea3b734 to your computer and use it in GitHub Desktop.
(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