Created
March 16, 2009 09:05
-
-
Save sross/79799 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 remove-all (elts list &key (key #'identity) (test #'eql)) | |
"Removes all elements of ELTS from LIST. This is similar to set-difference with the exception | |
that the order of the elements in LIST is preserved." | |
(remove-if #'(lambda (elt) (member (funcall key elt) elts :test test)) list)) | |
(defun all-same-order-p (list-of-lists &key (test #'eql)) | |
"Returns true if the lists in LIST-OF-LISTS are all in the same order." | |
(flet ((same-order-p (list1 list2) | |
(let ((diff (set-exclusive-or list1 list2 :test test))) | |
(equal (remove-all diff list1 :test test) | |
(remove-all diff list2 :test test))))) | |
(loop for (first . rest) on list-of-lists | |
:always (loop for other in rest | |
:always (same-order-p first other))))) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment