home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 9 / 09.iso / l / l210 / 1.ddi / EXAMPLES.ARC / CH08EX04.PRO < prev    next >
Encoding:
Text File  |  1988-06-21  |  481 b   |  22 lines

  1. /*
  2.    Turbo Prolog 2.0 Chapter 8, Example Program 4
  3.    
  4.    Copyright (c) 1986, 88 by Borland International, Inc
  5.    
  6. */
  7.     
  8. trace
  9. domains
  10.    list = integer*
  11.  
  12. predicates
  13.    add1(list, list)
  14.  
  15. clauses
  16.    add1([], []). /* boundary condition */
  17.    add1([Head|Tail], [Head1|Tail1]) :- /* separate the head */
  18.  /* from the rest of the list */
  19.       Head1= Head+1, /* add 1 to the first element */
  20.       add1(Tail, Tail1). /* call element with the rest of the
  21. list */
  22.