Skip to content

Add unordered-equal from https://www.cs.northwestern.edu/academics/co… #42

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion lisp-unit.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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 :test test) (count x1 l2 :test test))) l1)))