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 / lc.icn < prev    next >
Text File  |  2000-07-29  |  872b  |  40 lines

  1. ############################################################################
  2. #
  3. #    File:     lc.icn
  4. #
  5. #    Subject:  Program to count lines in file
  6. #
  7. #    Author:   Ralph E. Griswold
  8. #
  9. #    Date:     July 19, 1994
  10. #
  11. ############################################################################
  12. #
  13. #   This file is in the public domain.
  14. #
  15. ############################################################################
  16. #
  17. #  This program simply counts the number of lines in standard input
  18. #  and writes the result to standard output.
  19. #
  20. #  Assumes UNIX-style line terminators.
  21. #
  22. #  Requires lots of memory as written.
  23. #
  24. ############################################################################
  25.  
  26. procedure main()
  27.    local count, line
  28.  
  29.    count := 0
  30.  
  31.    while line := reads(, 1000000) do
  32.       line ? {
  33.          every upto('\n') do
  34.             count +:= 1
  35.          }
  36.  
  37.    write(count)
  38.  
  39. end
  40.