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

  1. /*
  2.    Turbo Prolog 2.0 Chapter 8, Example Program 1
  3.    
  4.    Copyright (c) 1986, 88 by Borland International, Inc
  5.    
  6. */
  7.    
  8. domains
  9.    list = integer* /* or whatever type you wish to use */
  10.  
  11. predicates
  12.    write_a_list(list)
  13.  
  14. clauses
  15.    write_a_list([]). /* If the list is empty, do nothing more. */
  16.  
  17.    write_a_list([H|T]) :- /* Match the head to H and the tail to
  18. T, then... */
  19.       write(H), nl,
  20.       write_a_list(T).
  21.  
  22. goal
  23.    write_a_list([1, 2, 3]).
  24.