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 / ipl / progs / tabulate.icn < prev    next >
Text File  |  2000-07-29  |  922b  |  40 lines

  1. ############################################################################
  2. #
  3. #    File:     tabulate.icn
  4. #
  5. #    Subject:  Program to tabulate lines in a file
  6. #
  7. #    Author:   Ralph E. Griswold
  8. #
  9. #    Date:     February 28, 1999
  10. #
  11. ############################################################################
  12. #
  13. #  This file is in the public domain.
  14. #
  15. ############################################################################
  16. #
  17. #  This program produces a tabulation showing how many times each
  18. #  line of a file occurs.
  19. #
  20. ############################################################################
  21. #
  22. #  Links:  options
  23. #
  24. ############################################################################
  25.  
  26. link options
  27.  
  28. procedure main(args)
  29.    local opts, tabulation
  30.  
  31.    tabulation := table(0)
  32.  
  33.    while tabulation[read()] +:= 1
  34.  
  35.    tabulation := sort(tabulation, 3)
  36.  
  37.    while write(get(tabulation), "  ", right(get(tabulation), 6))
  38.  
  39. end
  40.