Prolog Programming
A concordance is "an index of words occurring in a passage of text".
Write an interactive concordance generator that keeps track of words
and a count of the number of times they have been used.
The program must repeatedly prompt the user:
(W)ord, (D)isplay, (S)earch, or e(X)it :
and accept a character input to select an option.
The actions for each option are:
- W - Prompt the user to input a word to add to the concordance.
If the word is not in the concordance yet, add it with a count of 1.
If the word is already in the concordance, increment its count.
- D - Display the concordance.
- S - Prompt the user to input a word, then search the concodance and
report the number of times the word has been used.
- X - Exit.
The data structure for the program must be a list of functions of arity one.
The functors are the words, and the argument is the number of times the
word has been used.
The list must be maintained in alphabtic order of the words.
For example:
[cat(3),dog(5),rat(1),sat(2)]