summaryrefslogtreecommitdiff
path: root/ipl/progs/iseq.icn
blob: c3466fc35132b7b2b24ef6c67306f3e19e0f30a6 (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
49
50
############################################################################
#
#	File:     iseq.icn
#
#	Subject:  Program to write sequence of integers
#
#	Author:   Ralph E. Griswold
#
#	Date:     November 3, 1996
#
############################################################################
#
#  This file is in the public domain.
#
############################################################################
#
#  This program generates integers in sequence.
#
#  The following options are supported:
#
#	-b i	beginning integer; default 1
#	-e i	ending integer; default no end
#	-i i	increment; default 1
#	-l i	limit on number of integers generated; default no limit
#
#  Large integer values are not supported.
#
############################################################################
#
#  Links:  options
#
############################################################################

link options

procedure main(args)
   local opts, limit, start, stop, incr, i

   opts := options(args, "b+e+i+l+")

   limit := \opts["l"] | (2 ^ 32)		# good enough
   start := \opts["b"] | 1
   stop := \opts["e"] | (2 ^ 64)		# sort of good enough
   incr := \opts["i"] | 1

   every i := seq(start, incr) \ limit do
      if i > stop then exit()
      else write(i)

end