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

Constructing Data Structures

  $\mbox{$\bullet$}$
We may want to know who is spouse of who
?- married(couple(peter, S)).
S = anna

?- married(couple(marcia, S)).
no
  $\mbox{$\bullet$}$
Argument order matters, of course
  $\mbox{$\bullet$}$
We must specify what is a spouse
spouse(couple(A, B), A).
spouse(couple(A, B), B).
  $\mbox{$\bullet$}$
Then we can forget about the order
?- spouse(C, peter), married(C).
C = couple(peter,anna)

?- married(C), spouse(C, marcia).
C = couple(alvin,marcia)

?- spouse(C, luca), married(C).
no



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