home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / historic / v941.tgz / icon.v941src.tar / icon.v941src / tests / general / others.dat < prev    next >
Text File  |  2000-07-29  |  511b  |  24 lines

  1. #
  2. #    W O R D   T A B U L A T I O N
  3. #
  4.  
  5. #  This main procedure processes standard input and writes the results
  6. #  with the words in a column 20 characters wide.
  7.  
  8. procedure main()
  9.    wordcount(20)
  10. end
  11.  
  12. procedure wordcount(n)
  13.    local t, line, x, y
  14.    static letters
  15.    initial letters := &lcase ++ &ucase
  16.    t := table(,0)
  17.    every line := !&input do
  18.       scan line using
  19.          while tab(upto(letters)) do
  20.             t[tab(many(letters))] +:= 1
  21.    x := sort(t)
  22.    every y := !x do write(left(y[1],n),y[2])
  23. end
  24.