CS 224 Lab 6 - Prolog
Objectives:
For the query
ancestor(X,bob).
there are two possible values of the variable X which make this query true. Prolog will print the first that it finds. If you then type a semicolon , prolog will look for another possible value for X. Type a semicolon once more and prolog will search for another answer and this time fails.
Note: Variables in prolog are always capitalized and constants are always lower case.
Assignment:
Write a relation membst which determines whether a value K is a member of a binary search tree.
Test your relation with the following queries:
membst(3,node(5,node(3,nil,nil),node(7,nil,nil))).
membst(6, node(5,node(3,nil,nil),node(7,nil,nil))).
Assignment:
Write a relation which may be used to find the last item in a list.
|
Assignment: Section 19.10 in the text describes "What Prolog is Good For" with an example of a little puzzle. Read this section and copy the file manwolf.pl from ~jillz/cs224 and complete exercise 21 on p417 |