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

  1. /*
  2.    Turbo Prolog 2.0 Chapter 8, Example Program 2
  3.    
  4.    Copyright (c) 1986, 88 by Borland International, Inc
  5.    
  6. */
  7.    
  8. domains
  9.    list = integer* /* or whatever type you want to use */
  10.  
  11. predicates
  12.    length_of(list, integer)
  13.  
  14. clauses
  15.    length_of([], 0).
  16.    length_of([_|T], L) :- length_of(T, TailLength),
  17.                          L = TailLength + 1.
  18.  
  19.