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 / papply.icn < prev    next >
Text File  |  2000-07-29  |  1KB  |  43 lines

  1. ############################################################################
  2. #
  3. #    File:     papply.icn
  4. #
  5. #    Subject:  Program to apply procedure to lines of file
  6. #
  7. #    Author:   Ralph E. Griswold
  8. #
  9. #    Date:     May 31, 1994
  10. #
  11. ############################################################################
  12. #
  13. #   This file is in the public domain.
  14. #
  15. ############################################################################
  16. #
  17. #  This program applies the procedure given as a command-line argument
  18. #  to each line of standard input, writing out the results.  For example,
  19. #
  20. #    papply reverse <foo
  21. #  
  22. #  writes out the lines of foo reversed end-for-end.
  23. #
  24. #  As it stands, there is no way to provide other arguments.  That' easy
  25. #  to remedy.
  26. #
  27. #  Except for use with (built-in) functions, this program needs to be linked
  28. #  with procedures that might be used with it.
  29. #
  30. ############################################################################
  31.  
  32. invocable all
  33.  
  34. procedure main(args)
  35.    local p, line
  36.  
  37.    p := proc(get(args)) | stop("*** invalid or missing procedure")
  38.  
  39.    while line := read() do
  40.       write(p(line))
  41.  
  42. end
  43.