The contents of :facts can be displayed at any time by using the primitive print - by typing pr :facts. If you would rather see the current set of facts as a vertical list, then get hold of vprint from the Toolbox and use vprint :facts.
Otherwise, as far as the top-level user is concerned, there are four system specific commands:
Each of the other three commands takes one list as input. These lists may be of any length.
Learn adds a list representing a fact to the database. I.e. it puts the new fact at the head of (in the first position of) :facts. It will not allow duplication of a fact already in the database.
Forget removes a list representing a fact or tells you if no such fact is recorded anyway.
Query is the interrogation command, accepting a list representing 'question' as input.
The input to query may also be a list containing occurrences of ? - a question mark used as a wild-card. The wild-card takes the place of the English question words what, where etc. in wh-questions. Unlike normal English question words, however, it is only used in positions in the input list where a corresponding full word is expected to be found in a database fact. [? is red] would, in other words, be used to elicit a response containing [roses is blue] and [blood is red], while [blood is ?] would be used to get the reply [blood is red] (always assuming such facts were in the database).
Notice that a ? substitutes for a single word and not a phrase (although Things to do with the Facts database suggests removing this restriction.) But notice also that it is possible with the wild-card to ask questions which would not be possible using English question words. [? ? ?], for example, could be used to retrieve any three word fact.
Beware of copying and pasting from this page. Run-on lines are represented here by indentation. A ready to run version is available.
to cleanup make "facts [] end to learn :fact if member? :fact :facts [pr [I know that already] stop] make "facts fput :fact :facts ( pr [O.K.] :fact ) END to forget :fact if not member? :fact :facts [pr [I didn't know that anyway] stop] make "facts remove :fact :facts ( pr [O.K.] :fact [is forgotten] ) end to query :question pr check :question :facts end to check :question :data if empty? :data [op []] if match? :question first :data [op fput first :data check :question bf :data] op check :question bf :data end to match? :this :that if and ( empty? :this ) ( empty? :that ) [op "true] if or ( first :this ) = ( first :that ) ( first :this ) = "? [op match? bf :this bf :that][op "false] end
E-mail: ron.brasington@rdg.ac.uk