home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / prolog / library / prolo_c / exampl16.pro < prev    next >
Text File  |  1986-10-06  |  842b  |  32 lines

  1. /* Program 16 */
  2. /*
  3.   This program will find pairs. Enter the goal:
  4.      findpairs.
  5. */
  6.  
  7. domains
  8.     name,sex,interest = symbol
  9.     interests = interest*
  10.  
  11. predicates
  12.     findpairs
  13.     person(name,sex,interests)
  14.     member(interest,interests)
  15.     common_interest(interests,interests,interest)
  16.  
  17. clauses
  18.     findpairs if person(Man, m, ILIST1 ) and
  19.         person( Woman, f, ILIST2 ) and
  20.         common_interest( ILIST1, ILIST2, _ ) and
  21.         write( Man, " might like  ",Woman ) and nl and
  22.         fail.
  23.      findpairs:- write ("---end of the list---\n").
  24.         common_interest( IL1, IL2, X ) if
  25.         member(X, IL1 ) and member(X, IL2) and !.
  26.  
  27.      person(tom,m,[travel,books,baseball]).
  28.      person(mary,f,[wine,books,swimming,travel]).
  29.  
  30.      member( X, [X|_] ).
  31.      member( X, [_|L] ) if member( X, L ).
  32.