/** *************************************************************************************************************************** *this is only applicable using the database that Jamie has used during his lecture. in this case its lecture 17 [l17] database* *************************************************************************************************************************** **/ bad(x) :- bad(x). /** this is prolog version of "fun f x = f x" in ML **/ /** these loops are very easy to generate **/ heads(win, jamie). /** returns false, lecture video (pretty early, about 9min in.) **/ tails(win, jamie). /** returns an error of "out of local stack", as there are subgoals for "tails" call in the database **/ /** *************************************************************************************************************************** * database manipulations * *************************************************************************************************************************** **/ film(good, high-anxiety). /** returns an error of "undefined procedure" **/ asserta(film(good, high-anxiety)). /** inserts a entry in the database of "film(good, high-anxiety)." **/ asserta(film(good, terminator)). /** inserts an entry for "film(good, terminator)." **/ /** "asserta" adds entries to the begining of the database **/ /** entries are added to the dynamic database. **/ asserta(plays(charles)). /** insters an entry for "plays(charles)." **/ /** would return an error as dynamic database is unable to predicates that already exist in the static database **/ /** dynamic and static databases are completely separe **/ film(bad, prometheus). /** once the static database has an entry with the same predicate as an entry in dynamic database, all entries with that predicate are wiped form dynamic database **/ assertz(bad, terminator). /** adds entry to the end of the database **/ /** entries can only be added to either begining or end of the database **/ /** once prolog is closed both the dynamic and static databases are removed from memory **/ retract(film(bad, terminator)). /** removes the entry for "film(bad, terminator)." **/ retract(film(X, Y)). /** it matches and deletes clauses it finds, unless "enter" or "y" is pressed. **/ abolish(film/2). /** abolishes all predicates which require 2 arrities for the named predicate **/ /** removes the information about the predicate as well **/ retractall(film(X, Y)). /** removes all entries withtout inquiring of the user/programmer **/ /** keeps the information about the predicate, but removes the entries **/ retractall(X). /** removes all entries, but provides a warning "did not clear exception" **/ check_invitations(N). /** returns an initial of "N=3" instanciation **/ /** imperative and function languagess **/