home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 9 / 09.iso / l / l210 / 1.ddi / EXAMPLES.ARC / CH18EX04.PRO < prev    next >
Encoding:
Prolog Source  |  1988-06-21  |  588 b   |  28 lines

  1. /*
  2.    Turbo Prolog 2.0 Chapter 18, Example Program 4
  3.    
  4.    Copyright (c) 1986, 88 by Borland International, Inc
  5.    
  6. */
  7.    
  8. domains
  9.    d = integer
  10.  
  11. predicates
  12.    not_(D, D)
  13.    and_(D, D, D)
  14.    or_(D, D, D)
  15.    xor(D, D, D)
  16.  
  17. clauses
  18.    not_(1, 0).       not_(0, 1).
  19.    and_(0, 0, 0).    and_(0, 1, 0).
  20.    and_(1, 0, 0).    and_(1, 1, 1).
  21.    or_(0, 0, 0).     or_(0, 1, 1).
  22.    or_(1, 0, 1).     or_(1, 1, 1).
  23.  
  24.    xor(Input1, Input2, Output) :- 
  25.       not_(Input1, N1), not_(Input2, N2),
  26.       and_(Input1, N2, N3), and_(Input2, N1, N4),
  27.       or_(N3, N4, Output).
  28.