Reading and writing


next up previous
Next: Changing the database
Up: Supplement 7
Previous: Introduction
Back: to main list of student notes

Reading and writing

First, please write a command predicate called tax that takes five arguments. The first argument is an initial; the second is a title (i.e. 'Mr' ); the third is a surname; the fourth is an address. All these are atoms. The fifth is a number, representing an amount of money in pounds. An example of its use: the question

    tax( 'D', 'Mr', 'Jones', 'Honeysuckle Cottage, Woodtown', 2500 ).
should display the message
      Attn: Mr. D. Jones, Honeysuckle Cottage, Woodtown.

      Dear Mr. Jones.
          You owe the sum of 2500 pounds in taxes for the year 1988-89.
      Unless you pay this within a period of 7 days,  your possessions,
      including any children you may have  accrued, will be  liable  to
      distraint in order to pay the above-mentioned sum of 2500 pounds.

Secondly, the knowledge base MOW contains a predicate of one argument, which must be a number. Load this by typing library(mow), and see what it does with questions like

    mow(0).
    mow(4).

Write a predicate which types a sensible message asking for a number, then reads a number, and calls mow with that number as argument.


next up previous
Next: Changing the database
Up: Supplement 7
Previous: Introduction
Back: to main list of student notes



Jocelyn Paine
Tue Jun 4 18:10:48 BST 1996