summaryrefslogtreecommitdiff
path: root/ipl/progs/repeats.icn
blob: 5a272edaea1e8afebccc1451d7c94542e41e137a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
############################################################################
#
#	File:     repeats.icn
#
#	Subject:  Program to repeat stream
#
#	Author:   Ralph E. Griswold
#
#	Date:     January 21, 1999
#
############################################################################
#
#  This file is in the public domain.
#
############################################################################
#
#  This program repeat the input stream.  The following options are
#  supported:
#
#	-l i	limit on length of input stream; default 1000.
#	-r i	number of time input stream is repeated; default no limit.
#
#  Note that the input stream must be limited, since it is stored internally.
#
############################################################################
#
#  Links:  options
#
############################################################################

link options

procedure main(args)
   local opts, limit, repeats, values

   opts := options(args, "l+r+")

   limit := \opts["l"] | 1000
   repeats := \opts["2"] | (2 ^ 20)		# kludge ...

   values := []

   every put(values, !&input) \ limit

   every 1 to repeats do
      every write(!values)

end