(3rd y 2nd)) ;3rd follows 2nd down the list.
((atom 2nd) 3rd)
(rplacd 2nd 3rd)))
+
+
+(defun intersection (list1 list2 &key (test #'eql) (key #'identity))
+ (let ((new-list ()))
+ (dolist (x list1)
+ (when (member x list2 :test test :key key)
+ (push x new-list)))
+ new-list))
fdefinition fifth find-package find-symbol first flet format fourth
fset funcall function functionp gensym get-internal-real-time
get-setf-expansion get-universal-time go identity if in-package
- incf integerp intern keywordp labels lambda last length let let* list
- list* list-all-packages listp loop make-array make-package
- make-symbol mapcar member minusp mod multiple-value-bind
+ incf integerp intern intersection keywordp labels lambda last length
+ let let* list list* list-all-packages listp loop make-array
+ make-package make-symbol mapcar member minusp mod multiple-value-bind
multiple-value-call multiple-value-list multiple-value-prog1
nconc nil ninth not nreconc nth nthcdr null numberp or otherwise
package-name package-use-list packagep pairlis parse-integer plusp
(test (equal (member 4 '((1 . 2) (3 . 4)) :key #'cdr) '((3 . 4))))
(test (member '(2) '((1) (2) (3)) :test #'equal))
+; INTERSECTION
+(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))))
+
; SUBST
; Can't really test this until EQUAL works properly on lists