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
/
ipower.icn
< prev
next >
Wrap
Text File
|
2000-07-29
|
1KB
|
53 lines
############################################################################
#
# File: ipower.icn
#
# Subject: Program to write sequence of powers
#
# Author: Ralph E. Griswold
#
# Date: December 29, 1996
#
############################################################################
#
# This file is in the public domain.
#
############################################################################
#
# This program generates integers in sequence.
#
# The following options are supported:
#
# -v i value to be raise to power; default 2
# -b i beginning power; default 1
# -e i ending power; default no end
# -i i increment; default 1
# -l i limit on number of powers generated; default no limit
#
# Large integer values are not supported.
#
############################################################################
#
# Links: options
#
############################################################################
link options
procedure main(args)
local opts, limit, start, stop, incr, i, base
opts := options(args, "v+b+e+i+l+")
limit := \opts["l"] | (2 ^ 32) # good enough
base := \opts["v"] | 2
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(base ^ i)
end