next up previous contents index
Next: Adding an element to Up: Set Operations Previous: Set Operations   Contents   Index

Checking for a member in a set: `memberp'

This abstraction is applicable for lists in general and also for sets specifically checking, whether a certain element is contained in the list or set.

The difference between the abstraction `locate' and `memberp' consists in the first argument being a condition for `memberp' and not a predicate function.

`memberp' appears in this category because it is used by the abstraction `create a union of two sets'.

(define memberp (lambda(x s)
(if (nullp s)
(if (equaln x (car s)
(memberp x (cdr s)))))))

(define l1 (cons one (cons two (cons three
...rp three l1))
--> true
(bdisp! (memberp five l1))
--> false

domain access counter Georg P. Loczewski 2004-03-05