12.4 Exercises

Exercise  12.1 Write code that creates hogwart.houses , a file that that looks like this:

                 gryffindor
   hufflepuff          ravenclaw
                 slytherin

You can use the built-in predicates open/3 , close/1 , tab/2 , nl/1 , and write/2 .

Exercise  12.2 Write a Prolog program that reads in a plain text file word by word, and asserts all read words and their frequency into the Prolog database. You may use the predicate readWord/2 to read in words. Use a dynamic predicate word/2 to store the words, where the first argument is a word, and the second argument is the frequency of that word.

eXTReMe Tracker
© 2006-2012 Patrick Blackburn, Johan Bos, Kristina Striegnitz