These functions all manipulate lists.
> (append '(1 2 3) '(4 5 6)) ;concatenate lists
(1 2 3 4 5 6)
> (reverse '(1 2 3)) ;reverse the elements of a list
(3 2 1)
> (member 'a '(b d a c)) ;set membership -- returns the first tail
(A C) ;whose car is the desired element
> (find 'a '(b d a c)) ;another way to do set membership
A
> (find '(a b) '((a d) (a d e) (a b d e) ()) :test #'subsetp)
(A B D E) ;find is more flexible though
> (subsetp '(a b) '(a d e)) ;set containment
NIL
> (intersection '(a b c) '(b)) ;set intersection
(B)
> (union '(a) '(b)) ;set union
(A B)
> (set-difference '(a b) '(a)) ;set difference
(B)
Subsetp
, intersection
, union
, and set-difference
all assume that each
argument contains no duplicate elements -- (subsetp '(a a) '(a b b))
is
allowed to fail, for example.
Find
, subsetp
, intersection
, union
, and
set-difference
can all take a
:test
keyword argument; by default, they all use eql
.