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 >
Text File  |  2000-07-29  |  1KB  |  53 lines

  1. ############################################################################
  2. #
  3. #    File:     ipower.icn
  4. #
  5. #    Subject:  Program to write sequence of powers
  6. #
  7. #    Author:   Ralph E. Griswold
  8. #
  9. #    Date:     December 29, 1996
  10. #
  11. ############################################################################
  12. #
  13. #  This file is in the public domain.
  14. #
  15. ############################################################################
  16. #
  17. #  This program generates integers in sequence.
  18. #
  19. #  The following options are supported:
  20. #
  21. #    -v i    value to be raise to power; default 2
  22. #    -b i    beginning power; default 1
  23. #    -e i    ending power; default no end
  24. #    -i i    increment; default 1
  25. #    -l i    limit on number of powers generated; default no limit
  26. #
  27. #  Large integer values are not supported.
  28. #
  29. ############################################################################
  30. #
  31. #  Links:  options
  32. #
  33. ############################################################################
  34.  
  35. link options
  36.  
  37. procedure main(args)
  38.    local opts, limit, start, stop, incr, i, base
  39.  
  40.    opts := options(args, "v+b+e+i+l+")
  41.  
  42.    limit := \opts["l"] | (2 ^ 32)        # good enough
  43.    base := \opts["v"] | 2
  44.    start := \opts["b"] | 1
  45.    stop := \opts["e"] | (2 ^ 64)        # sort of good enough
  46.    incr := \opts["i"] | 1
  47.  
  48.    every i := seq(start, incr) \ limit do
  49.       if i > stop then exit()
  50.       else write(base ^ i)
  51.  
  52. end
  53.