Created
October 12, 2013 16:04
-
-
Save Eskatrem/6951681 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 eq-assoc (assoc-a assoc-b) | |
(and (equal (length assoc-a) (length assoc-b)) | |
(reduce (lambda (accum pair) | |
(and accum | |
(equal pair (assoc (car pair) assoc-b)))) | |
assoc-a | |
:initial-value t))) | |
(defun group (list) | |
(let ((even t)) | |
(remove nil (maplist (lambda (l) | |
(if (not (setf even (not even))) | |
(cons (car l) (cadr l)))) | |
list)))) | |
(defun your-test (list-a list-b) | |
(eq-assoc (group list-a) (group list-b))) | |
(defun test () | |
(let ((one '(a b c d)) | |
(two '(c d a b)) | |
(three '(a c b d))) | |
(and (your-test one one) (your-test two two) | |
(your-test one two) (your-test two one) | |
(not (your-test one three)) (not (your-test three one)) | |
(not (your-test two three)) (not (your-test two three))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment