home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 9 / 09.iso / l / l217 / 2.ddi / EXAMPLES / CH06EX03.PRO < prev    next >
Encoding:
Prolog Source  |  1990-03-26  |  2.5 KB  |  64 lines

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