`eqv?`

is used to test for membership by procedures which treat
lists as sets.

— Function: **adjoin**` e l`

`adjoin`

returns the adjoint of the elementeand the listl. That is, ifeis inl,`adjoin`

returnsl, otherwise, it returns`(cons`

el`)`

.Example:

(adjoin 'baz '(bar baz bang)) ⇒ (bar baz bang) (adjoin 'foo '(bar baz bang)) ⇒ (foo bar baz bang)

— Function: **union**` l1 l2`

`union`

returns a list of all elements that are inl1orl2. Duplicates betweenl1andl2are culled. Duplicates withinl1or withinl2may or may not be removed.Example:

(union '(1 2 3 4) '(5 6 7 8)) ⇒ (1 2 3 4 5 6 7 8) (union '(0 1 2 3 4) '(3 4 5 6)) ⇒ (5 6 0 1 2 3 4)

— Function: **intersection**` l1 l2`

`intersection`

returns a list of all elements that are in bothl1andl2.Example:

(intersection '(1 2 3 4) '(3 4 5 6)) ⇒ (3 4) (intersection '(1 2 3 4) '(5 6 7 8)) ⇒ ()

— Function: **set-difference**` l1 l2`

`set-difference`

returns a list of all elements that are inl1but not inl2.Example:

(set-difference '(1 2 3 4) '(3 4 5 6)) ⇒ (1 2) (set-difference '(1 2 3 4) '(1 2 3 4 5 6)) ⇒ ()

— Function: **subset?**` list1 list2`

Returns

`#t`

if every element oflist1is`eqv?`

an element oflist2; otherwise returns`#f`

.Example:

(subset? '(1 2 3 4) '(3 4 5 6)) ⇒ #f (subset? '(1 2 3 4) '(6 5 4 3 2 1 0)) ⇒ #t

— Function: **member-if**` pred lst`

`member-if`

returns the list headed by the first element oflstto satisfy`(`

predelement`)`

.`Member-if`

returns`#f`

ifpredreturns`#f`

for everyelementinlst.Example:

(member-if vector? '(a 2 b 4)) ⇒ #f (member-if number? '(a 2 b 4)) ⇒ (2 b 4)

— Function: **some**` pred lst1 lst2 ...`

predis a boolean function of as many arguments as there are list arguments to`some`

i.e.,lstplus any optional arguments.predis applied to successive elements of the list arguments in order.`some`

returns`#t`

as soon as one of these applications returns`#t`

, and is`#f`

if none returns`#t`

. All the lists should have the same length.Example:

(some odd? '(1 2 3 4)) ⇒ #t (some odd? '(2 4 6 8)) ⇒ #f (some > '(1 3) '(2 4)) ⇒ #f

— Function: **every**` pred lst1 lst2 ...`

`every`

is analogous to`some`

except it returns`#t`

if every application ofpredis`#t`

and`#f`

otherwise.Example:

(every even? '(1 2 3 4)) ⇒ #f (every even? '(2 4 6 8)) ⇒ #t (every > '(2 3) '(1 4)) ⇒ #f

— Function: **notany**` pred lst1 ...`

`notany`

is analogous to`some`

but returns`#t`

if no application ofpredreturns`#t`

or`#f`

as soon as any one does.

— Function: **notevery**` pred lst1 ...`

`notevery`

is analogous to`some`

but returns`#t`

as soon as an application ofpredreturns`#f`

, and`#f`

otherwise.Example:

(notevery even? '(1 2 3 4)) ⇒ #t (notevery even? '(2 4 6 8)) ⇒ #f

— Function: **list-of??**` predicate`

Returns a predicate which returns true if its argument is a list every element of which satisfies

predicate.

— Function: **list-of??**` predicate low-bound high-bound`

low-boundandhigh-boundare non-negative integers.`list-of??`

returns a predicate which returns true if its argument is a list of length betweenlow-boundandhigh-bound(inclusive); every element of which satisfiespredicate.

— Function: **list-of??**` predicate bound`

boundis an integer. Ifboundis negative,`list-of??`

returns a predicate which returns true if its argument is a list of length greater than`(-`

bound`)`

; every element of which satisfiespredicate. Otherwise,`list-of??`

returns a predicate which returns true if its argument is a list of length less than or equal tobound; every element of which satisfiespredicate.

— Function: **find-if**` pred lst`

`find-if`

searches for the firstelementinlstsuch that`(`

predelement`)`

returns`#t`

. If it finds any suchelementinlst,elementis returned. Otherwise,`#f`

is returned.Example:

(find-if number? '(foo 1 bar 2)) ⇒ 1 (find-if number? '(foo bar baz bang)) ⇒ #f (find-if symbol? '(1 2 foo bar)) ⇒ foo

— Function: **remove**` elt lst`

`remove`

removes all occurrences ofeltfromlstusing`eqv?`

to test for equality and returns everything that's left. N.B.: other implementations (Chez, Scheme->C and T, at least) use`equal?`

as the equality test.Example:

(remove 1 '(1 2 1 3 1 4 1 5)) ⇒ (2 3 4 5) (remove 'foo '(bar baz bang)) ⇒ (bar baz bang)

— Function: **remove-if**` pred lst`

`remove-if`

removes allelements fromlstwhere`(`

predelement`)`

is`#t`

and returns everything that's left.Example:

(remove-if number? '(1 2 3 4)) ⇒ () (remove-if even? '(1 2 3 4 5 6 7 8)) ⇒ (1 3 5 7)

— Function: **remove-if-not**` pred lst`

`remove-if-not`

removes allelements fromlstfor which`(`

predelement`)`

is`#f`

and returns everything that's left.Example:

(remove-if-not number? '(foo bar baz)) ⇒ () (remove-if-not odd? '(1 2 3 4 5 6 7 8)) ⇒ (1 3 5 7)

— Function: **has-duplicates?**` lst`

returns

`#t`

if 2 members oflstare`equal?`

,`#f`

otherwise.Example:

(has-duplicates? '(1 2 3 4)) ⇒ #f (has-duplicates? '(2 4 3 4)) ⇒ #t

The procedure `remove-duplicates`

uses `member`

(rather than
`memv`

).