next up previous
Next: Constructing Recursive Data Structures: Up: Adding Computation Domains: CLP Previous: Constructing Recursive Data Structures:

Constructing Recursive Data Structures: Lists

  $\mbox{$\bullet$}$
Definition of membership:
member(Element, .(Element, List)).
member(Element, .(AnElement, RestList)):-
member(Element, RestList).
?- member(b, .(a, .(b, .(c, [])))).
yes

?- member(plof, .(a, .(b, .(c, [])))).
no

?- member(X, .(a, .(b, .(c, [])))).
X = a ? ;
X = b ? ;
X = c ?

?- member(a, .(a, .(X, .(c, [])))).
true ;
X = a



Last modification: Thu Oct 7 12:04:03 MEST 1999 <webmaster@clip.dia.fi.upm.es>