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

  1. /*
  2.    Turbo Prolog 2.0 Chapter 12, Example Program 7
  3.    
  4.    Copyright (c) 1986, 88 by Borland International, Inc
  5.    
  6. */
  7.    
  8. domains
  9.    person = p(name, age, telno, job)
  10.    age = integer
  11.    telno, name, job = string
  12.  
  13. predicates
  14.    readperson(person)
  15.    run
  16.  
  17. goal
  18.    run.
  19.  
  20. clauses
  21.    readperson(p(Name, Age, Telno, Job)) :-
  22.       write("Which name ? "), readln(Name),
  23.       write("Job ?"), readln(Job),
  24.       write("Age ?"), readint(Age),
  25.       write("Telephone no ?"), readln(Telno).
  26.  
  27.    run :-
  28.       readperson(P), nl, write(P), nl, nl,
  29.       write("Is this compound object OK (y/n)"),
  30.       readchar(Ch), Ch='y'.
  31.  
  32.    run :-
  33.       nl, nl, write("Alright, try again"), nl, nl, run.
  34.