// This module creates a hash to count all of the words in a file // named foo. It then prints out how many times the words // 'the' 'into' 'of' and 'love' are used. to wordCount(string s) into int count { int pos,string w; count = 0; for (;;) { (w, pos) = s.nextWord(pos); if (!w) break; count += 1; } } to split(string s) into array of string words { int count = wordCount(s); array[count] of string a; int i, pos, string word; for (i=0; i 0) fileName = args[0]; file f = fileOpen(fileName, "r"); string line; for (;;) { line = f.readLine(); if (!line) break; array of string words = split(line); for (string s in words) hash.addCount(s); } print("into is used " + hash.findCount("into") + " times."); print("of is used " + hash.findCount("of") + " times."); print("the is used " + hash.findCount("the") + " times."); print("love is used " + hash.findCount("love") + " times.");