Skip to content

Instantly share code, notes, and snippets.

@Eskatrem
Created October 12, 2013 16:04
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 Eskatrem/6951681 to your computer and use it in GitHub Desktop.
Save Eskatrem/6951681 to your computer and use it in GitHub Desktop.
(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