Make a simple knowledge base. Represent some of your favorite books and authors.
% books.pl book(sevenLanguagesInSevenWeeks). book(cleanCode). book(cleanCoder). book(programmingInScala). author(odersky). author(tate). author(martin). wrote(odersky, programmingInScala). wrote(tate, sevenLanguagesInSevenWeeks). wrote(martin, cleanCode). wrote(martin, cleanCoder).
Find all books in your knowledge base written by one author.
?- ['books']. % books compiled 0.00 sec, 13 clauses true. ?- wrote(martin, X). X = cleanCode ; X = cleanCoder.
Make a knowledge base representing musicians and instruments. Also represent musicians and their genre of music.
% music.pl instrument(flea, bass). instrument(hendrix, guitar). instrument(hancock, piano). instrument(cash, guitar). genre(flea, funk). genre(hendrix, blues). genre(hancock, jazz). genre(cash, country).
Find all musicians who play the guitar.
?- ['music']. % music compiled 0.00 sec, 10 clauses true. ?- instrument(X, guitar). X = hendrix ; X = cash.
No comments:
Post a Comment