-- tabulate the frequency of occurrence of each letter in a -- file of text with TEXT_IO; procedure frequencies is package int_io is new TEXT_IO.INTEGER_IO(INTEGER); use TEXT_IO, int_io; letter : CHARACTER; freq : array ('A'..'Z') of NATURAL := (others => 0); begin -- process each line in the file while not END_OF_FILE loop -- process each character of the line while not END_OF_LINE loop GET (letter); -- convert lower case letters to upper case if letter in 'a'..'z' then letter := CHARACTER'VAL ( CHARACTER'POS (letter) - CHARACTER'POS ('a') + CHARACTER'POS ('A') ); end if; -- tally the character (if it is a letter) if letter in 'A'..'Z' then freq(letter) := freq(letter) + 1; end if; end loop; SKIP_LINE; end loop; -- print the frequencies for letter in 'A'..'Z' loop PUT (letter & " : "); PUT (freq(letter), width => 6); NEW_LINE; end loop; end frequencies;