(rplacd 2nd 3rd)))
+(defun adjoin (item list &key (test #'eql) (key #'identity))
+ (if (member item list :key key :test test)
+ list
+ (cons item list)))
+
(defun intersection (list1 list2 &key (test #'eql) (key #'identity))
(let ((new-list ()))
(dolist (x list1)
(values-list /))
(export '(&body &key &optional &rest * ** *** *gensym-counter* *package* + ++
- +++ - / // /// 1+ 1- < <= = = > >= acons and append apply aref arrayp
- assoc atom block boundp butlast cadar caaar caadr cdaar cdadr
+ +++ - / // /// 1+ 1- < <= = = > >= acons adjoin and append apply aref
+ arrayp assoc atom block boundp butlast cadar caaar caadr cdaar cdadr
cddar caaaar caaadr caadar caaddr cadaar cadadr caddar cdaaar
cdaadr cdadar cdaddr cddaar cddadr cdddar cddddr caar cadddr caddr
cadr car car case catch cdar cdddr cddr cdr cdr char
(test (equal (member 4 '((1 . 2) (3 . 4)) :key #'cdr) '((3 . 4))))
(test (member '(2) '((1) (2) (3)) :test #'equal))
+; ADJOIN
+(test (equal (adjoin 1 '(2 3)) '(1 2 3)))
+(test (equal (adjoin 1 '(1 2 3)) '(1 2 3)))
+(test (equal (adjoin '(1) '((1) (2)) :test #'equal) '((1) (2))))
+
; INTERSECTION
(test (equal (intersection '(1 2) '(2 3)) '(2)))
(test (not (intersection '(1 2 3) '(4 5 6))))