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

  1. /*
  2.    Turbo Prolog 2.0 Chapter 6, Example Program 3
  3.    
  4.    Copyright (c) 1986, 88 by Borland International, Inc
  5.    
  6. */
  7.    
  8. domains
  9.    name = person(symbol, symbol)                             /* (First, Last) */
  10.    birthday = b_date(symbol, integer, integer)          /* (Month, Day, Year) */
  11.    ph_num = symbol                          /* Phone_number */
  12.  
  13. predicates
  14.    phone_list(name, symbol, birthday)
  15.    get_months_birthdays
  16.    convert_month(symbol, integer)
  17.    check_birthday_month(integer, birthday)
  18.    write_person(name)
  19.  
  20. clauses
  21.    get_months_birthdays :-
  22.       makewindow(1, 7, 7, " This Month's Birthday List ", 0, 0, 25, 80),
  23.       write(" First name\t Last Name\n"),
  24.       date(_, This_month, _),                  /* Get month from system clock */
  25.       phone_list(Person, _, Date),
  26.       check_birthday_month(This_month, Date),
  27.       write_person(Person), fail.
  28.  
  29.    get_months_birthdays :-
  30.       write("\n\n Press any key to continue: "),
  31.       readchar(_).
  32.  
  33.    write_person(person(First_name, Last_name)) :-
  34.       write("  ", First_name, "\t\t  ", Last_name), nl.
  35.  
  36.    check_birthday_month(Mon, b_date(Month, _, _)) :-
  37.       convert_month(Month, Month1),
  38.       Mon = Month1.
  39.    
  40.    phone_list(person(ed, willis), "767-8463", b_date(jan, 3, 1955)).
  41.    phone_list(person(benjamin, thomas), "438-8400", b_date(feb, 5, 1985)).
  42.    phone_list(person(ray, william), "555-5653", b_date(mar, 3, 1935)).
  43.    phone_list(person(thomas, alfred), "767-2223", b_date(apr, 29, 1951)).
  44.    phone_list(person(chris, grahm), "555-1212", b_date(may, 12, 1962)).
  45.    phone_list(person(dustin, robert), "438-8400", b_date(jun, 17, 1980)).
  46.    phone_list(person(anna, friend), "767-8463", b_date(jun, 20, 1986)).
  47.    phone_list(person(brandy, rae), "555-5653", b_date(jul, 16, 1981)).
  48.    phone_list(person(naomi, friend), "767-2223", b_date(aug, 10, 1981)).
  49.    phone_list(person(christina, lynn), "438-8400", b_date(sep, 25, 1981)).
  50.    phone_list(person(kathy, ann), "438-8400", b_date(oct, 20, 1952)).
  51.    phone_list(person(elizabeth, ann), "555-1212", b_date(nov, 9, 1984)).
  52.    phone_list(person(aaron, friend), "767-2223", b_date(nov, 15, 1987)).
  53.    phone_list(person(jennifer, caitlin), "438-8400", b_date(dec, 31, 1981)).
  54.  
  55.    convert_month(jan, 1).
  56.    convert_month(feb, 2).
  57.    convert_month(mar, 3).
  58.    convert_month(apr, 4).
  59.    convert_month(may, 5).
  60.    convert_month(jun, 6).
  61.    convert_month(jul, 7).
  62.    convert_month(aug, 8).
  63.    convert_month(sep, 9).
  64.    convert_month(oct, 10).
  65.    convert_month(nov, 11).
  66.    convert_month(dec, 12).
  67.