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

  1. ############################################################################
  2. #
  3. #    File:     repeats.icn
  4. #
  5. #    Subject:  Program to repeat stream
  6. #
  7. #    Author:   Ralph E. Griswold
  8. #
  9. #    Date:     January 21, 1999
  10. #
  11. ############################################################################
  12. #
  13. #  This file is in the public domain.
  14. #
  15. ############################################################################
  16. #
  17. #  This program repeat the input stream.  The following options are
  18. #  supported:
  19. #
  20. #    -l i    limit on length of input stream; default 1000.
  21. #    -r i    number of time input stream is repeated; default no limit.
  22. #
  23. #  Note that the input stream must be limited, since it is stored internally.
  24. #
  25. ############################################################################
  26. #
  27. #  Links:  options
  28. #
  29. ############################################################################
  30.  
  31. link options
  32.  
  33. procedure main(args)
  34.    local opts, limit, repeats, values
  35.  
  36.    opts := options(args, "l+r+")
  37.  
  38.    limit := \opts["l"] | 1000
  39.    repeats := \opts["2"] | (2 ^ 20)        # kludge ...
  40.  
  41.    values := []
  42.  
  43.    every put(values, !&input) \ limit
  44.  
  45.    every 1 to repeats do
  46.       every write(!values)
  47.  
  48. end
  49.