From d187e6613ead1ea1f79c99ad336ba69b6cb6171a Mon Sep 17 00:00:00 2001 From: Shannon Spires Date: Thu, 22 Mar 2018 13:23:53 -0600 Subject: [PATCH 1/3] Add unordered-equal from https://www.cs.northwestern.edu/academics/courses/325/programs/cs325/lisp-unit.lisp --- lisp-unit.lisp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lisp-unit.lisp b/lisp-unit.lisp index 317a69f..eb067fb 100644 --- a/lisp-unit.lisp +++ b/lisp-unit.lisp @@ -1052,3 +1052,14 @@ vice versa." (listp list2) (apply #'subsetp list1 list2 initargs) (apply #'subsetp list2 list1 initargs))) + + +;;; (UNORDERED-EQUAL l1 l2 :test) => true or false +;;; Return true if l1 is a permuation of l2. + +(defun unordered-equal (l1 l2 &key (test #'equal)) + (and (listp l1) + (listp l2) + (= (length l1) (length l2)) + (every #'(lambda (x1) (= (count x1 l1) (count x1 l2))) l1))) + From 36567140b5bbc181df9e38ce82c2c485c5ed5aa6 Mon Sep 17 00:00:00 2001 From: Shannon Spires Date: Fri, 23 Mar 2018 15:12:53 -0600 Subject: [PATCH 2/3] Export unordered-equal --- lisp-unit.lisp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lisp-unit.lisp b/lisp-unit.lisp index eb067fb..4f8170c 100644 --- a/lisp-unit.lisp +++ b/lisp-unit.lisp @@ -101,7 +101,7 @@ :test-run-complete :results) ;; Utility predicates - (:export :logically-equal :set-equal)) + (:export :logically-equal :set-equal :unordered-equal)) (in-package :lisp-unit) From ed3a8369fde99886e6c1b3ba5879c53576136a8d Mon Sep 17 00:00:00 2001 From: Shannon Spires Date: Thu, 9 Aug 2018 08:27:32 -0600 Subject: [PATCH 3/3] Fix unordered-equal to pay attention to its :test argument. --- lisp-unit.lisp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lisp-unit.lisp b/lisp-unit.lisp index 4f8170c..c91d4b1 100644 --- a/lisp-unit.lisp +++ b/lisp-unit.lisp @@ -1061,5 +1061,5 @@ vice versa." (and (listp l1) (listp l2) (= (length l1) (length l2)) - (every #'(lambda (x1) (= (count x1 l1) (count x1 l2))) l1))) + (every #'(lambda (x1) (= (count x1 l1 :test test) (count x1 l2 :test test))) l1)))