From: Ken Harris Date: Sun, 16 Jun 2013 04:59:00 +0000 (-0700) Subject: Bug fix: INTERSECTION doesn't apply :key to list1. X-Git-Url: http://repo.macrolet.net/gitweb/?a=commitdiff_plain;h=227c815341a7956c3bfff6b93f406c0d7b8cefb7;p=jscl.git Bug fix: INTERSECTION doesn't apply :key to list1. --- diff --git a/src/list.lisp b/src/list.lisp index 6b58aae..dabd201 100644 --- a/src/list.lisp +++ b/src/list.lisp @@ -317,6 +317,6 @@ (defun intersection (list1 list2 &key (test #'eql) (key #'identity)) (let ((new-list ())) (dolist (x list1) - (when (member x list2 :test test :key key) + (when (member (funcall key x) list2 :test test :key key) (push x new-list))) new-list)) diff --git a/tests/list.lisp b/tests/list.lisp index ac6ae90..4a99d8c 100644 --- a/tests/list.lisp +++ b/tests/list.lisp @@ -191,6 +191,9 @@ (test (equal (intersection '(1 2) '(2 3)) '(2))) (test (not (intersection '(1 2 3) '(4 5 6)))) (test (equal (intersection '((1) (2)) '((2) (3)) :test #'equal) '((2)))) +(test (equal '((1 . 2)) + (intersection '((1 . 2) (2 . 3)) '((9 . 2) (9 . 4)) + :test #'equal :key #'cdr))) ; POP (test (let* ((foo '(1 2 3))