From eba7fd9dc2d51fa1103b4598a9d1005dad7d4d39 Mon Sep 17 00:00:00 2001 From: gerd <gerd> Date: Fri, 18 Apr 2003 12:00:37 +0000 Subject: [PATCH] Fix for RANDOM-NSET-EXCLUSIVE-OR test case. NSET-EXCLUSIVE-OR used to return different results than SET-EXCLUSIVE-OR, and its algorithm doesn't appear to be easily fixable. Wait for someone who cares enough to fix the algorithm. * src/code/list.lisp (nset-exclusive-or): Implement in terms of SET-EXCLUSIVE-OR. --- code/list.lisp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/code/list.lisp b/code/list.lisp index 1d84582a5..fc88199f2 100644 --- a/code/list.lisp +++ b/code/list.lisp @@ -5,7 +5,7 @@ ;;; Carnegie Mellon University, and has been placed in the public domain. ;;; (ext:file-comment - "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/list.lisp,v 1.27 2002/11/20 16:14:33 toy Exp $") + "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/list.lisp,v 1.28 2003/04/18 12:00:37 gerd Exp $") ;;; ;;; ********************************************************************** ;;; @@ -813,6 +813,7 @@ ;;; the correct operation is performed depending on whether splice is at the ;;; top of the list or not +#+nil (defun nset-exclusive-or (list1 list2 &key (test #'eql) (test-not nil notp) key) "Destructively return a list with elements which appear but once in list1 @@ -843,6 +844,20 @@ (return ())) ; assume lists are really sets (t (setq splicey y)))))) +;;; +;;; The above #+nil'ed out version returns different results than +;;; SET-EXCLUSIVE-OR, for instance, for (SET-EXCLUSIVE-OR '(1 1) +;;; '(1)). Let's use SET-EXCLUSIVE-OR, and wait for someone who cares +;;; enough to fix the above algorithm. +;;; +(defun nset-exclusive-or (list1 list2 &key (test #'eql) (test-not nil notp) + key) + "Destructively return a list with elements which appear but once in list1 + and list2." + (if notp + (set-exclusive-or list1 list2 :key key :test-not test-not) + (set-exclusive-or list1 list2 :key key :test test))) + (defun subsetp (list1 list2 &key key (test #'eql testp) (test-not nil notp)) "Returns T if every element in list1 is also in list2." (declare (inline member)) -- GitLab