Summary Documentation: Basic Programs

Icon version 9.5.20f

adlcheck.icn: Program to check for bad address list data

This program checks address lists for correctness.

There are five options:

   -s      Check state (U.S. labels only)
   -z      Check ZIP code (U.S. labels only)
   -c      Check country name (a very heuristic check)
   -a      Check all of the above
   -d      Report addresses that exceed "standard dimensions" for labels:
              40 character line length, 8 lines per entry

[ Full documentation | Source code ]


adlcount.icn: Program to count address list entries

   This program counts the number of entries in an address list file.
If an argument is given, it counts only those that have designators
with characters in the argument. Otherwise, it counts all entries.

[ Full documentation | Source code ]


adlfiltr.icn: Program to filter address list entries

  This program filters address lists, allowing through only those entries
with specified selectors.

  The options are:

     -s arg  selects entries with characters in args (default is all)
     -x      inverts the logic, selecting characters not in args

[ Full documentation | Source code ]


adlfirst.icn: Program to write first line of addresses

   This program writes the first lines of entries in an address list file.
If an argument is given, it counts only those that have designators
with characters in the argument. Otherwise, it counts all entries.

[ Full documentation | Source code ]


adllist.icn: Program to list address list fields

This program lists entries in address lists. The options are:

   -c      by country
   -n      by name
   -C      by city (U.S. only)
   -s      by state (U.S. only)
   -z      by ZIP code (U.S. only)

   The default is -n.  If more than one option is specified, the
   order of dominance is -n -z -s -c -C.

[ Full documentation | Source code ]


adlsort.icn: Program to sort address list entries

This program sorts entries in address lists.  The options are:

   -c      by country
   -n      by name
   -z      by ZIP code

   The default is -n.  If more than one option is specified, the
   order of dominance is -n -z -c.

[ Full documentation | Source code ]


animal.icn: Program to play "animal" guessing game

   This is the familiar ``animal game'' written in Icon.  The
program asks its human opponent a series of questions in an attempt
to guess what animal he or she is thinking of.  It is an ``expert
system'' that starts out with limited knowledge, knowing only one
question, but gets smarter as it plays and learns from its opponents.
At the conclusion of a session, the program asks permission to
remember for future sessions that which it learned.  The saved file
is an editable text file, so typos entered during the heat of battle
can be corrected.

   The game is not limited to guessing only animals.  By simply
modifying the first two lines of procedure "main" a program can be
created that will happily build a knowledge base in other categories.
For example, the lines:

        GameObject := "president"
        Tree := Question("Has he ever been known as Bonzo",
           "Reagan","Lincoln")

can be substituted, the program works reasonably well, and could even
pass as educational.  The knowledge files will automatically be kept
separate, too.

   Typing "list" at any yes/no prompt will show an inventory of
animals known, and there are some other commands too (see procedure
Confirm).

[ Full documentation | Source code ]


applyfnc.icn: Program to apply function to lines of a file

This program applies a function specified on the command line to the
lines of a file.

[ Full documentation | Source code ]


banner.icn: Program to display banner

   Here is a a handy little code fragment called banner. I
know icon is mostly in the unix world and unix already has a banner
command. But I'm mostly in the DOS and VMS world so I offer this little
banner code. It outputs enlarged letters (5x6 matrix) portraite. With a
little diddling you can change the scale or font since this is the source.
Maybe it can be made to take an input file as a font, and maybe even from
xwindows. But this is a simple one. I include a main() procedure that
calls it so you can test it and build from there. Enjoy!

[ Full documentation | Source code ]


based.icn: Program to do BASIC-style editing

This program models a line editor for BASIC.

[ Full documentation | Source code ]


bfd.icn: Program to compute best-fit-descending bin packing

Usage:  bpack binsize [options] [file]

Input:  one entry per line, size in decimal followed by anything else
        (anything else presumably being a file name or something)

Output: all the input lines, unchanged but reordered,
        with an empty line before each bin and a total afterward

Options:
     -t      don't output anything except unannotated totals
     -n      don't output anything except the *number* of bins
     -b i    don't output anything except the details from bin i

[ Full documentation | Source code ]


bj.icn: Program to play blackjack game

Simple but fun blackjack game.  The original version was for an ANSI
screen.  This version has been modified to work with the UNIX termcap
database file.

[ Full documentation | Source code ]


blnk2tab.icn: Program to convert strings of 2 or more blanks to tabs

This program converts strings of two or more blanks to tabs.  It
reads from standard input and writes to standard output.

[ Full documentation | Source code ]


c2icn.icn: Program to assist C-to-Icon porting

Filter to do some of the mundane work involved in porting a C
program to Icon.

- Reformats comments, moving embedded comments to end of line
- Removes the ";" from ends of lines
- Reformats line-continued strings
- Changes = to :=
- Changes -> to .

[ Full documentation | Source code ]


calc.icn: Program to simulate desk calculator

This is a simple Polish "desk calculator".  It accepts as values Icon
integers, reals, csets, and strings (as they would appear in an Icon
program) as well as an empty line for the null value.

Other lines of input are interpreted as operations. These may be Icon
operators, functions, or the commands listed below.

In the case of operator symbols, such as +, that correspond to both unary
and binary operations, the binary one is used.  Thus, the unary operation
is not available.

In case of Icon functions like write() that take an arbitrary number of
arguments, one argument is used.

The commands are:

     clear   remove all values from the calculator's stack
     dump    write out the contents of the stack
     quit    exit from the calculator

Example: the input lines

     "abc"
     3
     repl
     write

writes abcabcabc and leaves this as the top value on the stack.

Failure and most errors are detected, but in these cases, arguments are
consumed and not restored to the stack.

[ Full documentation | Source code ]


catlines.icn: Program to concatenate lines of a file

This program concatenates all the lines from standard input and
writes the result to standard output.

[ Full documentation | Source code ]


chars.icn: Program to list the different characters in a file

This program lists all the different characters in a file.  image()
is used to show printable representations.

[ Full documentation | Source code ]


chkhtml.icn: Program to check HTML files

Program to check an HTML file.

Errors detected:

  - Reference to undefined anchor name.
  - Duplicated anchor name.
  - Warning for unreferenced anchor name.
  - Unknown tag.
  - Badly formed tag.
  - Improper tag nesting.
  - Unescaped <, >, ", or &.
  - Bad escape string.
  - Improper embedding of attributes.
  - Bad (non-ascii) characters

Advises on:
  - Use of <HTML>, <HEAD, <BODY> tags.

[ Full documentation | Source code ]


choose.icn: Program to pick lines from a file

usage:  choose [-N] [file...]

This program randomly selects N lines from the input stream and
outputs them in order.  If N is omitted, one line is chosen.
If the input stream supplies fewer than N lines, all are output.

[ Full documentation | Source code ]


chop.icn: Program to restrict numerical values

This program limits the numerical values in a sequence
visualization stream.  The limit is given on the command line;
default 200.

[ Full documentation | Source code ]


colm.icn: Program to arrange data into columns

Program to arrange a number of data items, one per line, into
multiple columns. Items are arranged in column-wise order, that is,
the sequence runs down the first column, then down the second, etc.

If a null line appears in the input stream, it signifies a break in
the list, and the following line is taken as a title for the
following data items. No title precedes the initial sequence of
items.

Usage:

      colm [-w line_width] [-s space_between] [-m min_width]
              [-t tab_width] [-x] [-d] [file ...]

 The parameters are:

      line_width:     the maximum width allowed for output lines
                      (default: 80).
      space_between:  minimum number of spaces between items
                      (default: 2).
      min_width:      minimum width to be printed for each entry
                      (default: no minimum).
      tab_width:      tab width used to entab output lines.
                      (default: no tabs).
      -x              print items in row-wise order rather than
                      column-wise.
      -d (distribute) distribute columns throughout available width.

 The command "colm -h" generates "help" text.

 This is a  general utility,  but  it  was  written and tailored for a
 specific purpose:

 This  utility  was written  to rearrange the file name  list from the
 Macintosh  Programmer's   Workshop  "Files"  command  into   a   more
 convenient  format.  "Files" lists  file  names in a  single  column.
 This program  takes  the  list  produced by  "Files"  and  outputs  a
 multi-column  list.  The  names  are  listed  vertically within  each
 column, and  the column width is computed dynamically  depending upon
 the sizes  of the  names listed.  A  recommendation  is  to create  a
 command file "lc" (List in Columns) as follows:

      Files {"Parameters"} | colm

 The output from  the  Files command  is "piped" to the "colm" program
 (this program), which prints its list in the current window.

 By  putting both  the "lc"  command  file and the "colm" program into
 your {MPW}Tools folder, "lc" can be conveniently issued  as a command
 at any time, using the same parameters as the "Files" command.

[ Full documentation | Source code ]


comfiles.icn: Program to list common files in two directories

This program lists common file names in two directories given as
command-line arguments.

[ Full documentation | Source code ]


compare.icn: Program to look for duplicates in a collection of files

This program compares files to locate ones that have the same content.

The file names are given on the command line.

This program has impossible time complexity if there are many files
of the same size.

[ Full documentation | Source code ]


comply83.icn: Program to check compliance with MS-DOS name restrictions

This program checks the file names given on standard input and reports
any that are not valid MS-DOS file names.

It is designed handle output UNIX ls -R, but it will handle a list
of file names, one per line.

[ Full documentation | Source code ]


concord.icn: Program to produce concordance

   This program produces a simple concordance from standard input to standard
output. Words less than three characters long are ignored.

   There are two options:

     -l n    set maximum line length to n (default 72), starts new line
     -w n    set maximum width for word to n (default 15), truncates

   There are lots of possibilities for improving this program and adding
functionality to it. For example, a list of words to be ignored could be
provided.  The formatting could be made more flexible, and so on.

[ Full documentation | Source code ]


conman.icn: Program to convert units

Conman is a toy I used to teach myself elementary Icon.  I
once vaguely heard of a program which could respond to queries
like "? Volume of the earth in tbsp".

The keywords of the language (which are not reserved) are:

        load
        save
        print
        ? (same as print)
        list
        is and are which have the same effect

"Load" followed by an optional filename loads definitions of
units from a file.  If filename is not supplied, it defaults to
"conman.sav"

"Save" makes a file for "load".  Filename defaults to
"conman.sav".  "Save" appends to an existing file so a user
needs to periodically edit his save file to prune it back.

"Print" and "?" are used in phrases like:

        ? 5 minutes in seconds

Conman replies:

        5 minutes in seconds  equals  300

List puts up on the screen all the defined units and the
corresponding values.  Format is same as load/store format.

"Is" and "are" are used like this:

        100 cm are 1 meter

The discovery of is or are causes the preceding token (in
this case "cm") to be defined.  The load/store format is:

       unitname "is" value

Examples:

     8 furlongs is 1 mile
     furlong is 1 / 8 mile

These last two are equivalent.  Note spaces before and after
"/".  Continuing examples:

     1 fortnight is 14 days
     furlong/fortnight is furlong / fortnight
     inches/hour is inch / hour

After this a user might type:

     ? 1 furlong/fortnight in inches/hour

Conman will reply:

     1 furlong/fortnight in inches/hour equals 23.57

Note: the following feature of Conman:  his operators have no
precedence so the line above gets the right answer but

      1 furlong/fortnight in inches / hour

gets the wrong answer.  (One definition of a feature is a flaw we're
not going to fix).

[ Full documentation | Source code ]


countlst.icn: Program to count items in a list

   This program counts the number times each line of input occurs and
writes a summary.

   With no option, the output is sorted first by decreasing count and within
each count, alphabetically. With the option -a, the output is sorted
alphabetically.

The option -t prints a total at the end.

[ Full documentation | Source code ]


cross.icn: Program to display intersection of words

   This program takes a list of words and tries to arrange them
in cross-word format so that they intersect. Uppercase letters
are mapped into lowercase letters on input.  For example, the
input

        and
        eggplants
        elephants
        purple

produces the output
     +---------+
     | p       |
     | u e     |
     | r g     |
     | p g     |
     |elephants|
     | e l     |
     |   and   |
     |   n     |
     |   t     |
     |   s     |
     +---------+

Diagnostics: The program objects if the input contains a nonal-
phabetic character.

Comments: This program produces only one possible intersection
and it does not attempt to produce the most compact result.  The
program is not very fast, either.  There is a lot of room for
improvement here. In particular, it is natural for Icon to gen-
erate a sequence of solutions.

[ Full documentation | Source code ]


crypt.icn: Program to encrypt file

Do *not* use this in the face of competent cryptanalysis.

Usage: [iconx] icrypt [key] < infile > outfile

[ Full documentation | Source code ]


csgen.icn: Program to generate context-sensitive sentences

   This program accepts a context-sensitive production grammar
and generates randomly selected sentences from the corresponding
language.

   Uppercase letters stand for nonterminal symbols and -> indi-
cates the lefthand side can be rewritten by the righthand side.
Other characters are considered to be terminal symbols. Lines
beginning with # are considered to be comments and are ignored.
A line consisting of a nonterminal symbol followed by a colon and
a nonnegative integer i is a generation specification for i
instances of sentences for the language defined by the nontermi-
nal (goal) symbol.  An example of input to csgen is:

        #   a(n)b(n)c(n)
        #   Salomaa, p. 11.
        #   Attributed to M. Soittola.
        #
        X->abc
        X->aYbc
        Yb->bY
        Yc->Zbcc
        bZ->Zb
        aZ->aaY
        aZ->aa
        X:10

The output of csgen for this example is

        aaabbbccc
        aaaaaaaaabbbbbbbbbccccccccc
        abc
        aabbcc
        aabbcc
        aaabbbccc
        aabbcc
        abc
        aaaabbbbcccc
        aaabbbccc


   A positive integer followed by a colon can be prefixed to a
production to replicate that production, making its selection
more likely. For example,

        3:X->abc

is equivalent to

        X->abc
        X->abc
        X->abc

One option is supported:

     -g i    number of derivations; overrides the number specified
             in the grammar

Limitations: Nonterminal symbols can only be represented by sin-
gle uppercase letters, and there is no way to represent uppercase
letters as terminal symbols.

   There can be only one generation specification and it must
appear as the last line of input.

Comments: Generation of context-sensitive strings is a slow pro-
cess. It may not terminate, either because of a loop in the
rewriting rules or because of the progressive accumulation of
nonterminal symbols.  The program avoids deadlock, in which there
are no possible rewrites for a string in the derivation.

   This program would be improved if the specification of nonter-
minal symbols were more general, as in rsg.

[ Full documentation | Source code ]


cstrings.icn: Program to print strings in C files

Program to print all strings (enclosed in double quotes) in C source
files.

[ Full documentation | Source code ]


cwd.icn: Program to write current working directory

This program write the current working directory, shorn of it's
path specification.

For appropriately named directories, it can be used as, for example,

     ftp `cwd`

[ Full documentation | Source code ]


datmerge.icn: Program to merge data files

Datmerge reads and combines arbitrary text-based data files that
contain whitespace-separated data.  For each data field, a single
value is written to standard output after applying a selected
operator (such as median or minimum) to the corresponding values
from all the input files.

Usage:  datmerge [-operator] filename...

Operators:
    -min or -minimum
    -max or -maximum
    -med or -median   (this is the default)
    -mean

Values convertible to numeric are treated as such.
All others are treated as strings.

[ Full documentation | Source code ]


daystil.icn: Program to calculate the number of days until a given date

Usage:    daystil sMonth iDay

Returns:
    0   number of days written on &output
    1   Usage message on &errout (bad parameters)

Revision History:
    <1> njl  6/29/94 9:50 PM        First written

This program calculates the number of days between the current date
and the date specified on the command line, and writes this number to
&output.  This is useful if you want to know how many days it is
until a birthday, wedding day, etc.

The date on the command line can be specified in a variety of ways.
For instance, if you wanted to know how many days it is until
August 12 (my birthday), you could specify it as "August 12", "Aug 12",
"12 August", or "12 aUGuS", among others.  The match is case
insensitive, and the arguments will be accepted as long as exactly
one of them is an integer, and if there are exactly two arguments.

[ Full documentation | Source code ]


ddfdump.icn: Program to print the contents of an ISO 8211 DDF file

Usage:  ddfdump [file...]

Ddfdump prints the contents of Data Descriptive Files (DDF).
DDF is an incredibly complex file format enshrined by the
ISO 8211 standard and used by the United States Geological
Survey (USGS) for digital data.

[ Full documentation | Source code ]


deal.icn: Program to deal bridge hands

   This program shuffles, deals, and displays hands in the game
of bridge.  An example of the output of deal is
     ---------------------------------

               S: KQ987
               H: 52
               D: T94
               C: T82

     S: 3                S: JT4
     H: T7               H: J9863
     D: AKQ762           D: J85
     C: QJ94             C: K7

               S: A652
               H: AKQ4
               D: 3
               C: A653

     ---------------------------------

Options: The following options are available:

     -h n Produce n hands. The default is 1.

     -s n Set the seed for random generation to n.  Different
          seeds give different hands.  The default seed is 0.

[ Full documentation | Source code ]


declchck.icn: Program to detect possible declaration errors

This program examines ucode files and reports declared identifiers
that may conflict with function names.

[ Full documentation | Source code ]


delam.icn: Program to delaminate file

   This program delaminates standard input into several output
files according to the specified fields.  It writes the fields in
each line to the corresponding output files as individual lines.
If no data occurs in the specified position for a given input
line an empty output line is written. This insures that all out-
put files contain the same number of lines as the input file.

   If - is used for the input file, the standard input is read.
If - is used as an output file name, the corresponding field is
written to the standard output.

   The fields are defined by a list of field specifications,
separated by commas or colons, of the following form:

        n    the character in column n
        n-m  the characters in columns n through m
        n+m  m characters beginning at column n

where the columns in a line are numbered from 1 to the length of
the line.

   The use of delam is illustrated by the following examples.
The command

        delam 1-10,5 x.txt y.txt

reads standard input and writes characters 1 through 10 to file
x.txt and character 5 to file y.txt.  The command

        delam 10+5:1-10:1-10:80 mid x1 x2 end

writes characters 10 through 14 to mid, 1 through 10 to x1 and
x2, and character 80 to end.  The command

        delam 1-80,1-80 - -

copies standard input to standard output, replicating the first
eighty columns of each line twice.

[ Full documentation | Source code ]


delamc.icn: Program to delaminate file using tab characters

   This program delaminates standard input into several output
files according to the separator characters specified by the
string following the -t option.  It writes the fields in each
line to the corresponding output files as individual lines. If no
data occurs in the specified position for a given input line an
empty output line is written. This insures that all output files
contain the same number of lines as the input file.

   If - is used as an output file name, the corresponding field
is written to the standard output. If the -t option is not used,
an ascii horizontal tab character is assumed as the default field
separator.

   The use of delamc is illustrated by the following examples.
The command

        delamc labels opcodes operands

writes the fields of standard input, each of which is separated
by a tab character, to the output files labels, opcodes, and
operands.  The command

        delamc -t: scores names matric ps1 ps2 ps3

writes the fields of standard input, each of which are separated
by a colon, to the indicated output files.  The command

        delamc -t,: oldata f1 f2

separates the fields using either a comma or a colon.

[ Full documentation | Source code ]


dellines.icn: Program to delete lines from a file

This program is designed to delete a few specified lines from a file.
The line numbers are given on the command line, the file is read from
standard input and the lines that are not deleted are written to standard
output as in

     dellines 46 23 119 <infile >outfile

which writes all lines but 23, 46, and 119 of infile (if it contains that
many lines) to outfile.

Line numbers do not have to be given in order.  Numbers less than 1 are
ignored, but a nonnumerical argument is treated as an error.

[ Full documentation | Source code ]


delta.icn: Program to list differences between successive numbers

This program reads a stream of numbers from standard input and write
a stream of their first differences to standard output.

[ Full documentation | Source code ]


diffn.icn: Program to show differences among files

This program shows the differences between n files. Is is invoked as

     diffn file1 file2 ... filen

[ Full documentation | Source code ]


diffsort.icn: Program to reorder "diff" output

Usage:  diffsort [file]

Diffsort reorders the output from the Unix "diff" program by moving
one-line entries such as "Common subdirectory ..." and "Only in ..."
to the front of the output file and sorting them.  Actual difference
records then follow, in the original order, separated by lines of
equal signs.

[ Full documentation | Source code ]


diffsum.icn: Program to count lines affected by a diff

Usage:  diffsum [file]

Diffsum reads a file containing output from a run of the Unix "diff"
utility.  Diffsum handles either normal diffs or context diffs.  For
each pair of files compared, diffsum reports two numbers:
     1. the number of lines added or changed
     2. the net change in file size
The first of these indicates the magnitude of the changes and the
second the net effect on file size.

[ Full documentation | Source code ]


diffu.icn: Program to show differences in files

This program exercises the dif() procedure, making it act like the
UNIX diff(1) file difference command.

Usage: diffu f1 f2

     3d2
     < c
     7,8c6,7
     < g
     < h
     ---
     > i
     > j

[ Full documentation | Source code ]


diffword.icn: Program to list different words

This program lists all the different words in the input text.
The definition of a "word" is naive.

[ Full documentation | Source code ]


digcol.icn: Program to produce nth column of digit data

This program filters input to produce the nth column of digit date.

[ Full documentation | Source code ]


diskpack.icn: Program to produce packing list for diskettes

This program is designed to produce a list of files to fit onto
diskettes.  It can be adapted to other uses.

This program uses a straightforward, first-fit algorithm.

The options supported are:

    -s i    diskette capacity, default 360000
    -r i    space to reserve on first diskettes, default 0
    -n s    UNIX-style file name specification for files to
            be packed, default "*.lzh"

[ Full documentation | Source code ]


duplfile.icn: Program to find directories with same files

This program lists the file names that occur in more than one
subdirectory and the subdirectories in which the names occur.

This program should be used with caution on large directory
structures.

[ Full documentation | Source code ]


duplproc.icn: Program to find duplicate declarations

Use this if you plan on posting utility procedures suitable for
inclusion in someone's Icon library directories.

duplproc.icn compiles into a program which will search through
every directory in your ILIBS environment variable (and/or in the
directories supplied as arguments to the program).  If it finds any
duplicate procedure or record identifiers, it will report this on
the standard output.

It is important to try to use unique procedure names in programs
you write, especially if you intend to link in some of the routines
contained in the IPL.  Checking for duplicate procedure names has
been somewhat tedious in the past, and many of us (me included)
must be counted as guilty for not checking more thoroughly.  Now,
however, checking should be a breeze.

BUGS:  Duplproc thinks that differently written names for the same
directory are in fact different directories.  Use absolute path
names, and you'll be fine.

[ Full documentation | Source code ]


edscript.icn: Program to produce script for ed(1)

   This program takes specifications for global edits from standard
input and outputs an edit script for the UNIX editor ed to standard output.
Edscript is primarily useful for making complicated literal sub-
stitutions that involve characters that have syntactic meaning to
ed and hence are difficult to enter in ed.

   Each specification begins with a delimiter, followed by a tar-
get string, followed by the delimiter, followed by the replace-
ment string, followed by the delimiter.  For example

        |...|**|
        |****||

specifies the replacement of all occurrences of three consecutive
periods by two asterisks, followed by the deletion of all
occurrences of four consecutive asterisks.  Any character may be
used for the delimiter, but the same character must be used in
all three positions in any specification, and the delimiter char-
acter cannot be used in the target or replacement strings.

Diagnostic:

   Any line that does not have proper delimiter structure is noted
and does not contribute to the edit script.

Reference:

   "A Tutorial Introduction to the UNIX Text Editor", Brian W. Kernighan.
AT&T Bell Laboratories.

[ Full documentation | Source code ]


empg.icn: Program to make expression-evaluation programs

This program produces a program for evaluating Icon expressions.  The
input to this program has three forms, depending on the first character
of each line:

     :       the remainder of the line is an expression to be evaluated
             only once

     %       the remainder of the line is part of a declaration

     #       the remainder of the line is a comment and is ignored

Anything else is an expression to be evaluated in a loop.

For example, the input

# Time record access
%record complex(r, i)
:z := complex(1.0, 3.5)
z.r

produces a program to time z.r in a loop.

[ Full documentation | Source code ]


envelope.icn: Program to address envelopes

This program addresses envelopes on a Postscript or HP-LJ printer,
including barcodes for the zip code.  A line beginning with `#' or
an optional alternate separator can be used to separate multiple
addresses.  The parser will strip the formatting commands from an
address in a troff or LaTeX letter.

usage: envelope [options] < address(es)

Typically, envelope is used from inside an editor.  In emacs, mark
the region of the address and do
     M-| envelope
In vi, put the cursor on the first line of the address and do
     :,+N w !envelope
where N = number-of-lines-in-address.

The barcode algorithm is adapted from a perl script by Todd Merriman
<todd@toolz.uucp>, Dave Buck <dave@dlb.uucp>, and Andy Rabagliati
<andyr@wizzy.com>.

[ Full documentation | Source code ]


evaluate.icn: Program to evaluate Icon expressions

This program evaluates Icon operations given from standard input in
functional form.  It cannot handle nested expressions or control
structures.  See eval.icn for more details.

There is one option:

     -l i    limit on number of results from a generator; default 2 ^ 30

[ Full documentation | Source code ]


extweave.icn: Program to extract weaving specifications from weave file

This program extracts the weaving specifications from a Macintosh
Painter 5 weave file in MacBinary format.  (It might work on Painter 4
weave files; this has not been tested.)

The file is read from standard input.

The output consists of seven lines for each weaving specification in the
file:

     wave name
     warp expression
     warp color expression
     weft expression
     weft color expression
     tie-up
     blank separator

The tie-up is a 64-character string of 1s and 0s in column order. That
is, the first 8 character represent the first column of the tie-up. A
1 indicates selection, 0, non-selection.

This program does not produce the colors for the letters in color
expressions.  We know where they are located but haven't yet figured
out how to match letters to colors.

See Advanced Weaving, a PDF file on the Painter 5 CD-ROM.

[ Full documentation | Source code ]


farb.icn: Program to generate Farberisms

   Dave Farber, co-author of the original SNOBOL programming
language, is noted for his creative use of the English language.
Hence the terms ``farberisms'' and ``to farberate''.  This pro-
gram produces a randomly selected farberism.

Notes: Not all of the farberisms contained in this program were
uttered by the master himself; others have learned to emulate
him.  A few of the farberisms may be objectionable to some per-
sons.  ``I wouldn't marry her with a twenty-foot pole.''

[ Full documentation | Source code ]


farb2.icn: Program to generate Farberisms

   Dave Farber, co-author of the original SNOBOL programming
language, is noted for his creative use of the English language.
Hence the terms ``farberisms'' and ``to farberate''.  This pro-
gram produces a randomly selected farberism.

Notes: Not all of the farberisms contained in this program were
uttered by the master himself; others have learned to emulate
him.  A few of the farberisms may be objectionable to some per-
sons.  ``I wouldn't marry her with a twenty-foot pole.''

[ Full documentation | Source code ]


filecnvt.icn: Program to convert line terminators

   This program copies a text file, converting line terminators. It is
called in the form

     filecnvt [-i s1] [-o s2] infile outfile

The file name "-" is taken to be standard input or output, depending
on its position, although standard input/output has limited usefulness,
since it translates line terminators according the the system
being used.

   The options are:

     -i s1   assume the input file has line termination for the
               system designated by s1. The default is "u".

     -o s2   write the output file with line terminators for the
               system designated by s2. The default is "u".

The designations are:

     d       MS-DOS ("\n\r"); also works for the Atari ST
     m       Macintosh ("\r")
     u       UNIX ("\n"); also works for the Amiga

[ Full documentation | Source code ]


filehtml.icn: Program to create Web page with links to files

The files to be includes are listed on the command line.  There is no
check that the files actually exist.

[ Full documentation | Source code ]


fileprep.icn: Program to prepare file information for IPL indexes

This program creates files used in the construction of indexes for the
Icon program library.

[ Full documentation | Source code ]


fileprnt.icn: Program to display characters in file

   This program reads the file specified as a command-line argument and
writes out a representation of each character in several forms:
hexadecimal, octal, decimal, symbolic, and ASCII code.

   Input is from a named file rather than standard input, so that it
can be opened in untranslated mode.  Otherwise, on some systems, input
is terminated for characters like ^Z.

   Since this program is comparatively slow, it is not suitable
for processing very large files.

   There are several useful extensions that could be added to this program,
including other character representations, an option to skip an initial
portion of the input file, and suppression of long ranges of identical
characters.

[ Full documentation | Source code ]


filerepl.icn: Program to replicate file

This program writes standard input to standard a specified number of
times.  Number of replications is given on command line.

NOTE:  Since the input stream is stored internally, standard input
must be of finite length.

[ Full documentation | Source code ]


filesect.icn: Program to produce section of a file

This program writes the section of the input file starting at a
specified line number and extending a specified number of lines.

The specifications are given as integer command-line arguments; the
first is the starting line, the second is the number of lines.  For
example,

     filesect 20 100 <input >output

copies 100 lines from input to output, starting at line 20 of input.

If the specifications are out of range, the file written is truncated
without comment.

[ Full documentation | Source code ]


filexref.icn: Program to cross-reference files by components

Usage:

            dir dir1 /b /a:d > dirlist
            filexref < dirlist

Note:

            Dir does not preface its results with the parent directory
            - take care!

Options:

   -D       Produce an ascii delimited file
   -h       Exclude hidden files
   -n       Page Length ... must be integer >= 25

[ Full documentation | Source code ]


filtskel.icn: Program skeleton for generic filter

Generic filter skeleton in Icon.

This program is not intended to be used as is -- it serves as a
starting point for creation of filter programs.  Command line
options, file names, and tabbing are handled by the skeleton.  You
need only provide the filtering code.

As it stands, filter.icn simply copies the input file(s) to
standard output.

Multiple files can be specified as arguments, and will be processed
in sequence.  A file name of "-" represents the standard input file.
If there are no arguments, standard input is processed.

[ Full documentation | Source code ]


findstr.icn: Program to find embedded character strings

Utility filter to list character strings embedded in data files (e.g.
object files).

     findstr -options file...

     -l length       minimum string size to be printed (default 3)
     -c chars        a string of characters (besides the standard ASCII
                     printable characters) to be considered part of a
                     string

Icon string escape sequences can be used to specify the -c option.

Multiple files can be specified as arguments, and will be processed
in sequence.

[ Full documentation | Source code ]


findtext.icn: Program to retrieve data from files indexed by idxtext

 See documentation with idxtext.icn, gettext.icn, adjuncts.icn

History:
  (1.1) Tested with DOS, DOS-386, OS/2, ProIcon, UNIX
  (1.2) Use preprocessor include statement instead of link.

[ Full documentation | Source code ]


fixhqx.icn: Program to strip headers from BinHex files

Sometimes Macintosh .hqx files come with commentary before the
BinHex data.  This program strips off the heading material so that
BinHex can be used.

Input comes from standard input and output goes to standard output.

[ Full documentation | Source code ]


fixpath.icn: Program to replace path in a binary file

Usage:  fixpath filename oldpath newpath

Fixpath changes file paths or other strings in a binary file by modifying
the file in place.  Each null-terminated occurrence of "oldpath" is
replaced by "newpath".

If the new path is longer than the old one, a warning is given and the
old path is extended by null characters, which must be matched in the
file for replacement to take place.  This is dangerous in general but
allows repairing an errant fixpath command.

[ Full documentation | Source code ]


fnctab.icn: Program to list function usage

This program processes an MVT token file and tabulates the usage
of functions.

Since function usage cannot be determined completely from static
analysis, the results should be viewed with this limitation in mind.

[ Full documentation | Source code ]


fnctmpl.icn: Program to produce function templates

This program processes the rt.db database for the Icon compiler produced
by rtt and produces procedures for each Icon function to be used by
iftrace.icn.

The data base is expected from standard input.

[ Full documentation | Source code ]


format.icn: Program to word wrap a range of text

Filter to word wrap a range of text.

A number of options are available, including full  justification (see
usage text,  below).  All lines that have the same indentation as the
first  line (or same  comment leading character format if  -c option)
are wrapped.  Other lines are left as is.

This  program  is useful in conjunction with editors  that can invoke
filters on a range of selected text.

The -c option attempts to establish the form of a comment based on the
first  line, then does its best to deal  properly  with the following
lines.   The  types of  comment lines that  are handled  are those in
which  each  line starts with a "comment" character string  (possibly
preceded  by  spaces).  While formatting  comment  lines, text  lines
following the prototype line that don't match the  prototype  but are
flush with  the  left margin are also  formatted  as  comments.  This
feature simplifies  initially entering  lengthy  comments  or  making
major modifications, since  new  text can  be entered without concern
for comment formatting, which will be done automatically later.

[ Full documentation | Source code ]


former.icn: Program to format long string in fixed-length lines

This program takes a single line of input and outputs in in lines
no greater than the number given on the command line (default 80).

[ Full documentation | Source code ]


fract.icn: Program to approximate real number as a fraction

This program produces successive rational approximations to a real
number.

The options supported are:

     -n r    real number to be approximated, default .6180339887498948482
                (see below)

     -l i    limit on number of approximations, default 100 (unlikely to
                be reached).

[ Full documentation | Source code ]


fset.icn: Program to do set operations on file specifications

 The UNIX shell provides for the specification of filenames
using ``wildcards''.  Each wildcard specification may be
thought of as defining a set of names (that is, those that
match the specification).  Fset allows the user to apply the
set operations of intersection, union, and difference to
these filename sets. The resultant list may then be used as
an argument to other shell commands.

Fset's argument is an expression composed of legal UNIX file
specifications, parenthesis, and the following set opera-
tors:

     &&   intersection
     ++   union
     --   difference

Because characters that have special meaning to the shell
occur frequently in the arguments used for fset, it is
advisable to quote the arguments consistently.

The use of fset is illustrated by the following examples:

     fset 'g*--*.icn'

produces the list (set) of filenames for files beginning
with g, excluding those ending with .icn.

Similarly,

     fset '*'

produces all files in the current directory excluding the .
and .. files.

     fset '((*--*.icn)++c*)'
and

     fset '(*--*.icn)++c*'

produces the complement of all filenames ending with .icn in
addition to all filenames beginning with c.

     fset '(((c? && c*)))'

is a redundant, but legal, specification for all two-
character filenames that begin with c, while

     fset '.*'

produces the set of filenames for all hidden files, exclud-
ing the . and ..  files.

Limitations:

Multiple command line arguments, formed by omitting the
quotes around the file set expression, are permitted.  Their
use is limited, however, since parentheses do not get past
the shell's command-line expansion.

Almost any legal file specification will work when enclosed
in quotes except that the simple grammar that is used cannot
handle blanks adjacent to parentheses.

File names that begin or end in ``questionable'' characters
such as *, ?, +, -, and &, probably will not work.

A file specification that, when interpreted by the shell,
produces no matching filename will be placed (unchanged) in
the result.

[ Full documentation | Source code ]


fuzz.icn: Program to perform fuzzy pattern matching

   This program illustrates "fuzzy" string pattern matching.  The result
of matching s and t is a number between 0 and 1 which is based on
counting matching pairs of characters in increasingly long substrings
of s and t.  Characters may be weighted differently, and the reverse
tally may be given a negative bias.

[ Full documentation | Source code ]


gcomp.icn: Program to produce complement of file specification

   This program produces a list of the files in the current directory
that do not appear among the arguments.  For example,

     gcomp *.c

produces a list of files in the current directory that do
not end in .c.  As another example, to remove all the files
in the current directory that do not match Makefile, *.c, and *.h
the following can be used:

     rm `gcomp Makefile *.c *.h`

The files . and .. are not included in the output, but other
`dot files' are.

[ Full documentation | Source code ]


geddump.icn: Program to dump contents of GEDCOM file

usage:  geddump [file]

This program prints the genealogical information contained
in a GEDCOM file.  Individuals are printed alphabetically,
with sequence numbers to assist cross-referencing.

Marriages are noted for both partners.  Children are listed
under the father, or under the mother if no father is known.

[ Full documentation | Source code ]


gediff.icn: Program to "diff" for use with ged

Program to produce diff output in a format for use with ged's
"FindFileAndLine" (esc-S) command.  It causes the "diffed" files
to be open in the editor with the differing portions selected.

[ Full documentation | Source code ]


gener.icn: Program to generate sequence from Icon expression

This program takes an Icon expression is given on the command line, and
writes its results to standard output.  Watch for syntactic problems.

[ Full documentation | Source code ]


genfile.icn: Program to generate sequence from Icon expression in file

This program writes the results of an Icon expression given in the file
named on the command line.

[ Full documentation | Source code ]


genqueen.icn: Program to solve arbitrary-size n-queens problem

This program solve the non-attacking n-queens problem for (square) boards
of arbitrary size.  The problem consists of placing chess queens on an
n-by-n grid such that no queen is in the same row, column, or diagonal as
any other queen.  The output is each of the solution boards; rotations
not considered equal.  An example of the output for n:

    -----------------
    |Q| | | | | | | |
    -----------------
    | | | | | | |Q| |
    -----------------
    | | | | |Q| | | |
    -----------------
    | | | | | | | |Q|
    -----------------
    | |Q| | | | | | |
    -----------------
    | | | |Q| | | | |
    -----------------
    | | | | | |Q| | |
    -----------------
    | | |Q| | | | | |
    -----------------

Usage: genqueen n
where n is the number of rows / columns in the board.  The default for n
is 6.

[ Full documentation | Source code ]


getcol.icn: Program to extract column from data

This program extracts a column from multi-column data.

The supported options are:

    -n i    column number, default 1
    -c s    column-separation characters, default ' \t'

[ Full documentation | Source code ]


getlines.icn: Program to extract lines from a file

This program is designed to extract a few specified lines from a file.
The line numbers are given on the command line, the file is read from
standard input and the extracted lines are written to standard output
as in

     getlines 46 23 119 <infile >outfile

which writes lines 23, 46, and 119 of infile (if it contains that many
lines) to outfile.

Line numbers do not have to be given in order.  Numbers less than 1 are
ignored, but a nonnumerical argument is treated as an error.

[ Full documentation | Source code ]


gftrace.icn: Program for generating function tracing procedures

   This program writes a set of procedures to standard output.  Those
procedures can be linked with an Icon program to enable the tracing of
calls to built-in functions.  See the comments in the generated code
for details.

   The set of generated functions reflects the built-in functions of
the version of Icon under which this generator is run.

[ Full documentation | Source code ]


graphdem.icn: Program to demonstrate simple bar graphics

graph.icn: simple bar graphics package with two demo applications:
  1. display the 4 most frequently used characters in a string.
  2. display the fibonacci numbers

[ Full documentation | Source code ]


grpsort.icn: Program to sort groups of lines

   This program sorts input containing ``records'' defined to be
groups of consecutive lines. Output is written to standard out-
put.  Each input record is separated by one or more repetitions
of a demarcation line (a line beginning with the separator
string).  The first line of each record is used as the key.

   If no separator string is specified on the command line, the
default is the empty string. Because all input lines are trimmed
of whitespace (blanks and tabs), empty lines are default demarca-
tion lines. The separator string specified can be an initial sub-
string of the string used to demarcate lines, in which case the
resulting partition of the input file may be different from a
partition created using the entire demarcation string.

   The -o option sorts the input file but does not produce the
sorted records.  Instead it lists the keys (in sorted order) and
line numbers defining the extent of the record associated with
each key.

   The use of grpsort is illustrated by the following examples.
The command

        grpsort "catscats" <x >y

sorts the file x, whose records are separated by lines containing
the string "catscats", into the file y placing a single line of
"catscats" between each output record. Similarly, the command

        grpsort "cats" <x >y

sorts the file x as before but assumes that any line beginning
with the string "cats" delimits a new record. This may or may not
divide the lines of the input file into a number of records dif-
ferent from the previous example.  In any case, the output
records will be separated by a single line of "cats".  Another
example is

        grpsort -o <bibliography >bibkeys

which sorts the file bibliography and produces a sorted list of
the keys and the extents of the associated records in bibkeys.
Each output key line is of the form:

        [s-e] key

where

        s     is the line number of the key line
        e     is the line number of the last line
        key   is the actual key of the record

[ Full documentation | Source code ]


hcal4unx.icn: Program for Jewish/Civil calendar in UNIX

This work is respectfully devoted to the authors of two books
consulted with much profit: "A Guide to the Solar-Lunar Calendar"
by B. Elihu Rothblatt published by our sister Hebrew Dept. in
Madison, Wis., and "Kiddush HaHodesh" by Rabbenu Moses ben Maimon,
on whom be peace.

The Jewish year harmonizes the solar and lunar cycle, using the
19-year cycle of Meton (c. 432 BCE). It corrects so that certain
dates shall not fall on certain days for religious convenience. The
Jewish year has six possible lengths, 353, 354, 355, 383, 384, and
385 days, according to day and time of new year lunation and
position in Metonic cycle.  Time figures from 6pm previous night.
The lunation of year 1 is calculated to be on a Monday (our Sunday
night) at ll:11:20pm. Our data table begins with a hypothetical
year 0, corresponding to 3762 B.C.E.  Calculations in this program
are figured in the ancient Babylonian unit of halaqim "parts" of
the hour = 1/1080 hour.

Startup syntax is simply hebcalen [date], where date is a year
specification of the form 5750 for a Jewish year, +1990 or 1990AD
or 1990CE or -1990 or 1990BC or 1990BCE for a civil year.

[ Full documentation | Source code ]


headicon.icn: Program to add header to Icon program

This program prepends a standard header to an Icon program.  It does not
check to see if the program already has a header.

The first command-line argument is taken as the base
name of the file; default "foo".  The second command-line argument is
taken as the author; the default is "Ralph E. Griswold" -- with minor
apologies, I use this program a lot; personalize it for your own
use.

The new file is brought up in the vi editor.

The file skeleton.icn must be accessible via dopen().

[ Full documentation | Source code ]


hebcalen.icn: Program for combination Jewish/Civil calendar

This work is respectfully devoted to the authors of two books
consulted with much profit: "A Guide to the Solar-Lunar Calendar"
by B. Elihu Rothblatt published by our sister Hebrew Dept. in
Madison, Wis., and "Kiddush HaHodesh" by Rabbenu Moses ben Maimon,
on whom be peace.

The Jewish year harmonizes the solar and lunar cycle, using the
19-year cycle of Meton (c. 432 BCE). It corrects so that certain
dates shall not fall on certain days for religious convenience. The
Jewish year has six possible lengths, 353, 354, 355, 383, 384, and
385 days, according to day and time of new year lunation and
position in Metonic cycle.  Time figures from 6pm previous night.
The lunation of year 1 is calculated to be on a Monday (our Sunday
night) at ll:11:20pm. Our data table begins with a hypothetical
year 0, corresponding to 3762 B.C.E.  Calculations in this program
are figured in the ancient Babylonian unit of halaqim "parts" of
the hour = 1/1080 hour.

Startup syntax is simply hebcalen [date], where date is a year
specification of the form 5750 for a Jewish year, +1990 or 1990AD
or 1990CE or -1990 or 1990BC or 1990BCE for a civil year.

[ Full documentation | Source code ]


hebeng.icn: Program to print mixed Hebrew/English text

This program is written in ProIcon for the Macintosh computer. Alan D. Corre
August 1991. It takes input in a transcription of Hebrew which represents
current pronunciation adequately but mimics the peculiarities of Hebrew
spelling. Here are some sentences from the beginning of Agnon's story
"Friendship": marat qliyngel 'i$ah mefursemet haytah umenahelet beyt sefer
haytah qowdem liymowt hamilHamah. mi$eni$tanu sidrey ha`owlam,neHtexah
migdulatah..wexol miy $eyac'u low mowniyTiyn ba`owlam haytah mitqarevet
'eclow weyowce't wenixneset leveytow" The letter sin is represented by the
German ess-zed which is alt-s on the Mac and cannot be represented here.
The tilde (~)toggles between English and Hebrew, so the word "bar" will be
the English word "bar" or the Hebrew beyt-rey$ according to the current
mode of the program. Finals are inserted automatically. Justification
both ways occurs unless the program detects a blank or empty line, in
which case the previous line is not justified.
Since I took out non-ASCII chars, and have not rechecked that this
works with the corresponding octal chars, there could be some slips in
this text.

[ Full documentation | Source code ]


hotedit.icn: Program to edit a Mosaic hotlist

===> IMPORTANT NOTE:  This program was written for "NCSA Mosaic 2.4"
===> and is incompatible with the current version of Mosaic.

Hotedit makes it easy to edit the "hotlist" used with NCSA Mosaic,
a program for grazing the Wide World Web (WWW).  The Mosaic hotlist
is a text file, and it can be edited directly, but this is difficult
and error-prone.  Pairs of lines must be kept together, and the long
"Uniform Record Locator" (URL) lines make it hard to pick out the
title lines, which are of more interest.

Hotedit works by extracting the titles, bringing up an editor of the
user's choice, then processing the results when the editor exits.
The user can reorder, retitle, or delete lines; adding new entries
is best done within NCSA Mosaic.  It is vital that any editing
preserve the three-digit number at the front of each line; hotedit
uses this to reconnect the titles with the corresponding URLs.

The editor is determined by the environment variable VISUAL (or, if
that is missing, EDITOR).  The hotlist file is assumed to be in the
usual place, $HOME/.mosaic-hotlist-default.  Because not all editors
return a reasonable exit status, the hotlist is *always* rewritten;
the previous edition is saved in $HOME/.mosaic-hotlist-backup.

Hotedit shouldn't be run while NCSA Mosaic is running; when Mosaic
exits, it is likely to overwrite the edited hotlist.

[ Full documentation | Source code ]


hr.icn: Program to play horse-race game

This program implements a horse-race game.

[ Full documentation | Source code ]


htget.icn: Program to get Web file using HTTP protocol

Htget retrieves the raw text of a file from the world wide web using
HTTP protocol.  (Other protocols such as FTP are not supported.)

usage:  htget [-h | -b] URL

The URL may be given with or without the "http://" prefix.

If -h is given, a HEAD request is sent, requesting only information
instead of the complete file.

If -b is given, the header is stripped and the body is copied
in binary mode.

[ Full documentation | Source code ]


htprep.icn: Program to prepare HTML files

usage:  htprep [file]

Htprep is a filter for preparing HTML files (used, e.g., by Mosaic)
from a simpler and less error-prone input language.

The following transformations are applied:

     input           output
     ------------    ------------
     {}
     {!comment}      <!--comment-->
     {tag}           <tag>
     {tag ... }      <tag> ... <\tag>
       att=val...      att="val"...
     {@url ...       <a href="url" ...
     {:lbl ...       <a name="lbl" ...

Any input character can be preceded by a backslash (\) to prevent
special interpretation by htprep.

Output is normally to stdout, but the command
     {divert fname}
redirects output to the named file.  This can be used to produce
multiple related output files from a single input file.

[ Full documentation | Source code ]


huffstuf.icn: Program for huffman coding

An odd assortment of tools that lets me compress text using an
Iconish version of a generic Huffman algorithm.

[ Full documentation | Source code ]


hufftab.icn: Program to compute Huffman state transitions

   Each input line should be a string of 0s & 1s followed by a value
field.  Output is a list of items in a form suitable for inclusion
by a C program as initialization for an array.  Each pair of items
indicates the action to be taken on receipt of a 0 or 1 bit from the
corresponding state; this is either a state number if more decoding
is needed or the value field from the input if not.  State 0 is the
initial state;  0 is output only for undefined states.  States are
numbered by two to facilitate use of a one-dimensional array.

sample input:               corresponding output:
    00 a                        /*  0 */  2, c, a, 4, 0, b,
    011 b
    1 c                     [new line started every 10 entries]

Interpretation:
    from state 0,  input=0 => go to state 2,  input=1 => return c
    from state 2,  input=0 => return a,  input=1 => go to state 4
    from state 4,  input=0 => undefined,  input=1 => return b

[ Full documentation | Source code ]


ibar.icn: Program to equalize comment bars in Icon programs

This program replaces comment bars in Icon programs by bars 76 characters
long -- the program library standard.

[ Full documentation | Source code ]


ibrow.icn: Program to browse Icon files for declarations

Usage: ibrow [<Icon source file name>...]

If no source file names are provided on the command line, all *.icn
files in the current directory are browsed.

The program facilitates browsing of Icon programs.  It was originally
written to browse the Icon Program Library, for which purpose it
serves quite well.  The user interface is self-explanatory -- just
remember to use "?" for help if you're confused.

[ Full documentation | Source code ]


icalc.icn: Program to simulate infix desk calculator

This is a simple infix calculator with control structures and
  compound statements.  It illustrates a technique that can be
  easily used in Icon to greatly reduce the performance cost
  associated with recursive-descent parsing with backtracking.
  There are numerous improvements and enhancements that can be
  made.

Features include:

      - integer and real value arithmetic
      - variables
      - function calls to Icon functions
      - strings allowed as function arguments
      - unary operators:
            + (absolute value), - (negation)
      - assignment:
            :=
      - binary operators:
            +,-,*,/,%,^,
      - relational operators:
            =, !=, <, <=, >, >=
               (all return 1 for true and 0 for false)
      - compound statements in curly braces with semicolon separators
      - if-then and if-then-else
      - while-do
      - limited form of multiline input

The grammar at the start of the 'parser' proper provides more
  details.

Normally, the input is processed one line at a time, in calculator
  fashion.  However, compound statements can be continued across
  line boundaries.

Examples:

  Here is a simple input:

      {
      a := 10;
      while a >= 0 do {
         write(a);
         a := a - 1
         };
      write("Blastoff")
      }

   (execution is delayed until entire compound statement is entered)

  Another one:

  write(pi := 3.14159)
  write(sin(pi/2))

   (execution done as each line is entered)

[ Full documentation | Source code ]


icalls.icn: Program to tabulate Icon calls

This program processes trace output and tabulates calls of procedures

[ Full documentation | Source code ]


icn2c.icn: Program to assist Icon-to-C porting

Filter to do some mundane aspects of conversion of Icon to C.

- Reformats comments
- Reformats line-continued strings
- Changes := to =
- Reformats procedure declarations
- Changes end to "}"

[ Full documentation | Source code ]


icontent.icn: Program to list Icon procedures

Builds a list, in Icon comment format, of procedures and records
in an Icon source file.

Multiple files can be specified as arguments, and will be processed
in sequence.  A file name of "-" represents the standard input file.
If there are no arguments, standard input is processed.

usage: icontent <options> <Icon source file>...
     options:        -s      sort names alphabetically (default is in
                             order of occurrence)
                     -l      list in single column (default is to list
                             in multiple columns)

[ Full documentation | Source code ]


icvt.icn: Program for ASCII/EBCDIC program conversion

This program converts Icon programs from ASCII syntax to EBCDIC syntax
or vice versa. The option -a converts to ASCII, while the option
-e converts to EBCDIC. The program given in standard input is written
in converted form to standard output.

[ Full documentation | Source code ]


idepth.icn: Program to report maximum recursion depth

This program processes trace output and reports the maximum depth of
recursion.

[ Full documentation | Source code ]


idxtext.icn: Program for creating indexed text-base

    idxtext turns a file associated with gettext() routine into an
indexed text-base.  Though gettext() will work fine with files
that haven't been indexed via idxtext(), access is faster if the
indexing is done if the file is, say, over 10k (on my system the
crossover point is actually about 5k).

    Usage is simply "idxtext [-a] file1 [file2 [...]]," where file1,
file2, etc are the names of gettext-format files that are to be
(re-)indexed.  The -a flag tells idxtext to abort if an index file
already exists.

    Indexed files have a very simple format: keyname delimiter offset
[delimiter offset [etc.]]\n.  The first line of the index file is a
pointer to the last indexed byte of the text-base file it indexes.

BUGS: Index files are too large.  Also, I've yet to find a portable
way of creating unique index names that are capable of being
uniquely identified with their original text file.  It might be
sensible to hard code the name into the index.  The chances of a
conflict seem remote enough that I haven't bothered.  If you're
worried, use the -a flag. (RLG)

[ Full documentation | Source code ]


ifilter.icn: Program to filter lines of file

This program applies the operation given as a command-line argument
to each line of standard input, writing out the results.  For example,

     ifilter reverse <foo

writes out the lines of foo reversed end-for-end.

Trailing arguments can be given on the command line, as in

     ifilter right 10 0 <foo         # right(*, "10", "0")
     ifilter "%" 11 <foo             # * % "11"

The modules strings and numbers are linked to provide access to the
procedures they contain.  Except for these and operators and (built-in)
functions, this program needs to be linked with procedures to be
used with it.

The following options are supported:

     -a i    argument position for strings read in; default 1
     -o i    resolution of ambiguous operator string names, 1 for unary, 2
               for binary; default 2
     -l i    limit on generation, with nonpositive indicating
               no limitation; default 1

[ Full documentation | Source code ]


ifncsgen.icn: Program to generate procedure wrappers for functions

This program generates a procedure for every (built-in) function
that calls the function.

[ Full documentation | Source code ]


igrep.icn: Program for string search similar to egrep

Program to emulate UNIX egrep, but using the enhanced regular
expressions supported by regexp.icn.  Options supported are nearly
identical to those supported by egrep (no -b:  print disk block
number).  There is one additional option, -E, to allow Icon-type
(hence C-type) string escape sequences in the pattern string.
BEWARE:  when -E is used, backslashes that are meant to be processed
in the regular expression context must be doubled.  The following
patterns are equivalent:

 without -E: '\bFred\b'
 with    -E: '\\bFred\\b'

To enable the -D option (intended mainly for debugging), the Icon
Program Library file "ximage" must be linked with this program.

[ Full documentation | Source code ]


iheader.icn: Program to list Icon program library headers

This program lists the headers of Icon programs whose file names are
given on the command line.  It complains if the header does not start
correctly but otherwise does not check the syntax of what follows.

[ Full documentation | Source code ]


ihelp.icn: Program to give on-line help for Icon

ihelp -- Program to display "help" information

     ihelp [-f helpfile] [item] [keyword ...]

The optional item name specifies the section of the help file which
is to be displayed.  If no item name is specified a default section
will be displayed, which usually lists the help items that are
available.  An initial substring of the item name that differentiates
it from other items is sufficient.

If keyword(s) are specified, then only lines that contain all of the
keywords, in any order, are displayed.  The keywords do not have to
correspond to whole words in the help text; only to text fragments.

All item name and keyword matches are case independent.

The help file name is taken from environment variable "HELPFILE".  If
HELPFILE is not in the environment, file "help" in the current
directory is used.  A help file name specified in the -f option
overrides.

The help files are formatted as follows:

     default text lines
     -
     one
     item "one" text lines
     -
     two
     item "two" text lines
     ...

Sections are separated by lines containing a single "-".  Item names
are the first line following a separator line.

[ Full documentation | Source code ]


iidecode.icn: Program to decode text in style of uudecode

This is an Icon port of the UNIX/C uudecode utility.  Since
uudecode is publicly distributable BSD code, I simply grabbed a
copy, and rewrote it in Icon.  The only basic functional changes I
made to the program were:  (1) To simplify the notion of file mode
(everything is encoded with 0644 permissions), and (2) to add a
command-line switch for xxencoded files (similar to uuencoded
files, but capable of passing unscathed through non-ASCII EBCDIC
sites).

       usage:  iidecode [infile] [-x]

Usage is compatible with that of the UNIX uudecode command, i.e. a
first (optional) argument gives the name the file to be decoded.
If this is omitted, iidecode just uses the standard input.  The -x
switch (peculiar to iidecode) forces use of the the xxdecoding
algorithm.  If you try to decode an xxencoded file without speci-
-x on the command line, iidecode will try to forge ahead anyway.
If it thinks you've made a mistake, iidecode will inform you after
the decode is finished.


FIXES: Speeded up substantially (more than twice as fast on my
machine) by using a more icon-ish algorithm.  We decode in two
steps:

1)   The coded characters are mapped to "small bytes",
     each with 2 zero high bits, i.e. <<= "\x3F".
2)   We then 'pack' the small bytes by taking groups of 4 small bytes
     (each with 2 zero high bits and 6 data bits) and packing
     the data bits into groups of 3 bytes.

There are numerous advantages to this approach.  The icon map
function is much faster than the 'C'-ish alternatives.  We can
process things one line at a time. Also, the different decoding
mechanisms (old BSD, new BSD, xxdecode) can be produces by simply
using different map parameters.

[ Full documentation | Source code ]


iiencode.icn: Program to encode text in the style of uuencode

This is an Icon port of the UNIX/C uuencode utility.  Since
uuencode is publicly distributable BSD code, I simply grabbed a
copy, and rewrote it in Icon.  The only basic functional changes I
made to the program were:  (1) To simplify the notion of file mode
(everything is encoded with 0644 permissions), and (2) to add sup-
port for xxencode format (which will generally pass unscathed even
through EBCDIC sites).

Iiencode's usage is compatible with that of the UNIX uuencode
command, i.e. a first (optional) argument gives the name the file
to be encoded.  If this is omitted, iiencode just uses the standard
input.  The second argument specifies the name the encoded file
should be given when it is ultimately decoded.

Extensions to the base uuencode command options include -x and -o.
An -x tells iiencode to use xxencode (rather than uuencode) format.
Option -o causes the following argument to be used as the file
iiencode is to write its output to (the default is &output).  Note
that, on systems with newline translation (e.g. MS-DOS), the -o
argument should always be used.

  iiencode [infile] [-x] remote-filename [-o output-filename]


FIXES: Speeded up substantially (more than twice as fast on my
machine) by using a more icon-ish algorithm.  We encode in two
steps:

1)   We first "unpack" the bytes by taking groups of 3 bytes (24
     bits) and spreading them out by inserting two 0 bits before
     every block of 6 bits.  The result is that each group of 3
     bytes is unpacked to 4 "small bytes", each <<= "\x3F".
2)   The unpacked bytes are mapped to the coded line by using the
     Icon map function.

There are numerous advantages to this approach.  The Icon map
function is much faster than the 'C'-ish alternatives.  We can
process the file one line at a time. Also, the different encoding
mechanisms (old BSD, new BSD, xxencode) can be produces by simply
using different map parameters.

[ Full documentation | Source code ]


ilnkxref.icn: Program to produce Icon link cross reference

Utility to create cross reference of library files used in Icon
programs (i.e., those files named in "link" declarations).

     ilnkxref [-options] <icon source file>...

     options:

             -p      sort by "popularity"
             -v      report progress information

[ Full documentation | Source code ]


ilump.icn: Program to lump linked Icon source files

usage:  ilump [file...]

   ilump copies one or more Icon source files, incorporating recursively
the source code for files named by "link" directives.  This produces a
standalone source program in one file, which is useful with certain
profiling and visualization tools.

   Searching for link'd source files is similar to the action of Iconc
under UNIX.  If a link'd file is not found in the current directory,
directories specified by the LPATH environment variable are tried.

[ Full documentation | Source code ]


imagetyp.icn: Program to show types of image files

This program accepts file names from standard input and writes their
image type to standard output.

imagetyp(s) attempts to determine the type of image file named s.
This is, of course, problematical and corrupted or fake files can
easily fool it.  Furthermore, examples of some image files types
were not available for testing.

The types presently recognized are:

     value returned          image file type

     ps                      PostScript document
     cgm text                Computer Graphics Metafile, text
     cgm binary              Computer Graphics Metafile, binary
     cgm char                Computer Graphics Metafile, character
     sundraw                 SunDraw document
     ras                     UNIX raster image
     iris                    Iris image
     rle                     UNIX RLE image
     pbm                     PBM image
     pgm                     PGM image
     ppm                     PPM image
     xwd                     X Window dump
     gif                     Compuserv GIF image
     bmp                     BMP image
     xmp                     XMP image
     xpm                     XPM image
     pcx                     PCX image
     tiff                    TIFF image
     iff                     IFF/ILBM image
     ?                       unknown type

If the file cannot be opened or is empty, imagetyp() fails.

[ Full documentation | Source code ]


indxcomp.icn: Program to assist in index compilation

This program is designed to assist in the compilation of indexes.

It takes input from standard input and expects lines that either consist
of an integer (taken to be a page number) or text (to be indexed on
page of the last page number.

The idea is to go through the work to be indexed and create a file
in which the page number is entered followed by items to be indexed
on that page.  Page numbers (which need not be numeric) are prefixed
by "=".  For example, the file might consist of

     =1
     warts
     moles
     scratches
     =2
     scratches
     dents
     bumps
     =3
     hickies

The output of this program for that input is:

     bumps, 2
     dents, 2
     hickies, 3
     moles, 1
     scratches, 1, 2
     warts, 1

Leading blanks are stripped from index items.  Therefore to enter
an index item that begins with "=" start with " =" instead.

This program is unsophisticated.  It contains no provisions for
formatting index entries nor any way to indicated inclusive page
ranges.  Such things have to be done in post-processing.

non-numeric page "numbers" appear before numeric ones.

Obviously, there is room for improvement, embellishment, and creeping
featurism.

[ Full documentation | Source code ]


ineeds.icn: Program to print modules required by an Icon program

Program to determine Icon modules required by an Icon module.  Expects
environment variable LPATH to be set properly as for the Icon Compiler.

[ Full documentation | Source code ]


inter.icn: Program to find common values in two lists

This program lists lines common to two files.

[ Full documentation | Source code ]


interpe.icn: Program to interpret Icon expressions

  This program is a crude but effective interpreter for Icon expressions.
Each line entered from standard input is presumed to be an Icon
expression, is wrapped with a main procedure, and written to a pipe
that compiles and executes the resulting program.

  If the expression is a generator, all its results are produced.
If the command-line option -e is given, the expression is echoed.

  This technique is, of course, inefficient and may be painfully
slow except on the fastest platforms. This technique is, however,
completely general and as correct as Icon itself.

  Note:  This programs creates files with the names stdin, stdin.u1,
and stdin.u2. It removes them before terminating, but, of course,
overwrites any pre-existing files by these names.

[ Full documentation | Source code ]


interpp.icn: Program to interpret Icon programs

  This program is kind of like an interactive version of BASIC in that Icon
expressions are entered with line numbers and you can resequence them list
them etc. and execute all the lines entered.  There is no editor built
in.  You have to retype a line to change it.

  Documentation is lacking but there is a "?" help command that lists all
the other commands.

[ Full documentation | Source code ]


ipatch.icn: Program to patch iconx path in executable

Usage:  ipatch file path

   Ipatch changes the path to iconx, the Icon interpreter, that is
embedded in an Icon executable file under Unix.  Icon 9.4 headers are
rewritten in the same form.  Because headers from earlier versions of
Icon contain no room for expansion, they are rewritten in a different
form to accommodate a possibly-longer path.

[ Full documentation | Source code ]


ipldoc.icn: Program to collect library documentation

This program collects selected information from documentation headers
for Icon procedure files named on the command line.

The following options are supported:

     -s      skip file headers
     -f      sort procedure list by file; default sort by procedure
               name

[ Full documentation | Source code ]


iplindex.icn: Program to produce indexed listing of the program library

The following options are supported:

     -k i    width keyword field, default 16
     -p i    width of field for program name, default 12

   Some noise words are omitted (see "exceptions" in the program text).
If a file named except.wrd is open and readable in the current directory,
the words in it are used instead.

   This program is pretty simple.  Possible extensions include ways
of specifying words to be omitted, more flexible output formatting, and
so on.  Another "embellisher's delight".

   This program was derived from kwic.icn by Steve Wampler.

   The format of the output was suggested by Gregg Townsend.

[ Full documentation | Source code ]


iplkwic.icn: Program to produce keywords in context for IPL

   NOTE:  This is a specialized version used for producing kwic listings
for the Icon program library.

   This is a simple keyword-in-context (KWIC) program. It reads from
standard input and writes to standard output. The "key" words are
aligned at a specified column, with the text shifted as necessary. Text
shifted left is truncated at the left. Tabs and other characters whose
"print width" is less than one may not be handled properly.

The following options are supported:

     -c i    column at which keywords are aligned, default 30
     -h i    width of identifying column at left, default 20

   Some noise words are omitted (see "exceptions" in the program text).
If a file named except.wrd is open and readable in the current directory,
the words in it are used instead.

   This program is pretty simple.  Possible extensions include ways
of specifying words to be omitted, more flexible output formatting, and
so on.  Another "embellisher's delight".

[ Full documentation | Source code ]


iplweb.icn: Program to generate web pages from IPL header comments

iplweb [-ipl source] [dest]

Uses an environment variable IPL which is a path to the Icon Program Library
as a default if -ipl is not specified, dest is the current directory if not
specified.

Generates HTML directory in dest and makes an index to gprogs, gprocs,
procs, and progs directories under HTML.  In each of these directories
is a .html file for each of the .icn files in the referenced directory.
A index to all of these files is also generated.  Each of the .html files
contains the IPL standard comment header info inside.

[ Full documentation | Source code ]


ipower.icn: Program to write sequence of powers

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.

[ Full documentation | Source code ]


ipp.icn: Program to preprocess Icon programs

   Ipp is a preprocessor for the Icon language.  Ipp has many operations and
features that are unique to the Icon environment and should not be used as
a generic preprocessor (such as m4).  Ipp produces output which when written
to a file is designed to be the source for icont, the command processor for
Icon programs.

[ Full documentation | Source code ]


iprint.icn: Program to print Icon program

   The defaults are set up for printing of Icon programs, but
through command line options it can be set up to print programs
in other languages, too (such as C). This program has several
features:

   If a program is written in a consistent style, this program
will attempt to keep whole procedures on the same page. The
default is to identify the end of a print group (i.e. a pro-
cedure) by looking for the string "end" at the beginning of a
line. Through the -g option, alternative strings can be used to
signal end of a group. Using "end" as the group delimiter
(inclusive), comments and declarations prior to the procedure are
grouped with the procedure. Specifying a null group delimiter
string (-g '') suppresses grouping.

   Page creases are skipped over, and form-feeds (^L) embedded in
the file are handled properly. (Form-feeds are treated as spaces
by many C compilers, and signal page ejects in a listing). Page
headings (file name, date, time, page number) are normally
printed unless suppressed by the -h option.

   Options:

     -n   number lines.

     -pN  page length: number of lines per page (default: 60
          lines).

     -tN   tab stop spacing (default: 8).

     -h   suppress page headings.

     -l   add three lines at top of each page for laser printer.

     -gS  end of group string (default: "end").

     -cS  start of comment string (default: "#").

     -xS  end of comment string (default: none).

     -i   ignore FF at start of line.

   Any number of file names specified will be printed, each
starting on a new page.

   For example, to print C source files such as the Icon source
code, use the following options:

   iprint -g ' }' -c '/*' -x '*/' file ...

   Control lines:

   Control lines are special character strings that occur at the
beginnings of lines that signal special action. Control lines
begin with the start of comment string (see options). The control
lines currently recognized are:

   <comment string>eject -- page eject (line containing "eject"
does not print).

   <comment string>title -- define a title line to print at top
of each page. Title text is separated from the <comment
string>title control string by one space and is terminated by
<end of comment string> or end of line, whichever comes first.

   <comment string>subtitle -- define a sub-title line to print
at top of each page. Format is parallel to the "title" control
line, above.

   If a page eject is forced by maximum lines per page being
exceeded (rather than intentional eject via control line, ff, or
grouping), printing of blank lines at the top of the new page is
suppressed. Line numbers will still be printed correctly.

[ Full documentation | Source code ]


iprofile.icn: Program to profile Icon procedure usage

This very simple profiler takes a single argument - an Icon program
compiled with the -t option.  Displays stats on which procedures
were called the most often, and from what lines in what files they
were called.  Use this program to figure out what procedures are
getting worked the hardest and why.  Counts only invocations and
resumptions; not suspensions, returns, failures.

If you are running a program that reads from a file, be sure to
protect the redirection symbol from the shell (i.e. "profile
'myprog < input'" instead of "profile myprog < input").  If a given
program normally reads &input, please redirect stdin to read from
another tty than the one you are running profile from.  If you
forget to do this, the results might be very interesting....  Also,
don't redirect stderr, as this contains the trace that profile will
be reading and using to obtain run-time statistics.  Profile
automatically redirects stdout to /dev/null.

Currently runs only under UNIX, but with some tweaking could be
made to run elsewhere as well.

The display should be pretty much self-explanatory.  Filenames and
procedures get truncated at nineteen characters (if the display
gets too wide, it can become hard to read).  A star is prepended to
procedures whose statistics have changed since the last screen
update.

[ Full documentation | Source code ]


iprofl.icn: Program to annotate source code with execution profile

Iprofl combines Icon execution profiling output (see icont(1))
with source code files to produce an annotated listing.

Usage:   iprofl [file]

Iprofl reads an execution profile from a named file or from
standard input if none is specified.  Source files referenced
in the profile file are listed with corresponding nonzero profile
counts (ticks and visits) prepended to the left of each line.

Tick counts are given as a one-to-three-digit "per mille" value
(like a baseball "percentage") of the total number of ticks seen.
A value of "0" indicates a very small number of ticks whereas
a blank field indicates no ticks at all.

Iprofl lists only files in the current directory.  Files named in
the profile file but not found are only summarized.  This is not
considered an error because it is typical for library files to be
included in the profile output.

[ Full documentation | Source code ]


ipsort.icn: Program to sort Icon procedures

   This program reads an Icon program and writes an equivalent
program with the procedures sorted alphabetically. Global, link,
and record declarations come first in the order they appear in
the original program.  The main procedure comes next followed by
the remaining procedures in alphabetical order.

   Comments and white space between declarations are attached to
the next following declaration.

Limitations: This program only recognizes declarations that start
at the beginning of a line.

   Comments and interline white space between declarations may
not come out as intended.

   One option is accepted:

     -v      preserve VIB section at end

[ Full documentation | Source code ]


ipsplit.icn: Program to split Icon program into files

   This progam reads an Icon program and writes each procedure to
a separate file. The output file names consist of the procedure
name with .icn appended.  If the -g option is specified, any glo-
bal, link, and record declarations are written to that file. Oth-
erwise they are written in the file for the procedure that
immediately follows them.

   Comments and white space between declarations are attached to
the next following declaration.

Notes:

   The program only recognizes declarations that start at the
beginning of lines.  Comments and interline white space between
declarations may not come out as intended.

   If the -g option is not specified, any global, link, or record
declarations that follow the last procedure are discarded.

[ Full documentation | Source code ]


ipxref.icn: Program to cross reference Icon program

   This program cross-references Icon programs. It lists the
occurrences of each variable by line number. Variables are listed
by procedure or separately as globals.  The options specify the
formatting of the output and whether or not to cross-reference
quoted strings and non-alphanumerics. Variables that are followed
by a left parenthesis are listed with an asterisk following the
name.  If a file is not specified, then standard input is cross-
referenced.

Options: The following options change the format defaults:

     -c n The column width per line number. The default is 4
          columns wide.

     -l n The starting column (i.e. left margin) of the line
          numbers.  The default is column 40.

     -w n The column width of the whole output line. The default
          is 80 columns wide.

   Normally only alphanumerics are cross-referenced. These
options expand what is considered:

     -q   Include quoted strings.

     -x   Include all non-alphanumerics.

Note: This program assumes the subject file is a valid Icon pro-
gram. For example, quotes are expected to be matched.

[ Full documentation | Source code ]


irsort.icn: Program to sort Icon record declaration

   This program reads an Icon program and writes an equivalent
program with the record declaration sorted alphabetically at the
end. Global, link, invocable, and procedure declarations come in the order
they appear in the original program.

   Comments and white space between declarations are attached to
the next following declaration.

Limitations: This program only recognizes declarations that start
at the beginning of a line.

   Comments and interline white space between declarations may
not come out as intended.

Note:  This program is still raw.  White space and comments related
to records may not come out as expected.  A closed parenthesis in
a comment in the midst of a record declaration will cause havok.

[ Full documentation | Source code ]


irunerr.icn: Program to print Icon runtime errors

Program to list Icon runtime errors.

[ Full documentation | Source code ]


iseq.icn: Program to write sequence of integers

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.

[ Full documentation | Source code ]


isize.icn: Program to measure size of an Icon program

This program give several measures of the size of an Icon program.
The name of the program is given on the command line.

The command line option -t produces tab-separated values without
labeling instead of multipl labeled lines.

[ Full documentation | Source code ]


isrcline.icn: Program to count code lines in Icon program

This program counts the number of lines in a Icon program that actually
contain code, as opposed to being comments or blank lines.

Note:  preprocessor directives are counted as code lines.

[ Full documentation | Source code ]


istrip.icn: Program to strip comments from Icon program

This program strips comments out of an Icon program. It also removes
empty lines and leading whitespace (see stripcom.icn).

[ Full documentation | Source code ]


itab.icn: Program to entab an Icon program

itab -- Entab an Icon program, leaving quoted strings alone.

     itab [options] [source-program...]

     options:
             -i      Input tab spacing (default 8)
             -o      Outut tab spacing (default 8)

Observes Icon Programming Language conventions for escapes and
continuations in string constants.  If no source-program names are
given, standard input is "itabbed" to standard output.

[ Full documentation | Source code ]


itags.icn: Program to create tags file for Icon programs

Program to create a tags file for an Icon program.  It has the
options described in the Sun 3.5 man entry for ctags (except -u --
update tags file):

Usage: itags [-aBFtvwx] [-f tagsfile] file...

  -a   append output to an existing tags file.

  -B   use backward searching patterns (?...?).

  -F   use forward searching patterns (/.../) (default).

  -x   produce a list of object names,  the  line  number  and
       file name on which each is defined, as well as the text
       of that line and prints this on  the  standard  output.
       This  is  a simple index which can be printed out as an
       off-line readable function index.

  -t   create tags for records.

  -v   produce on the standard output an  index  of  the  form
       expected  by  vgrind(1).   This  listing  contains  the
       function name, file name, and page number (assuming  64
       line pages).  Since the output will be sorted into lex-
       icographic order, it may be desired to run  the  output
       through sort -f.  Sample use:
            itags -v files | sort -f > index
            vgrind -x index

  -w   suppress warning diagnostics.

[ Full documentation | Source code ]


itrbksum.icn: Program to give summary of traceback

This program summarizes traceback information produced on error
termination by filtering out the bulk of the procedure traceback
information.

Expect various options in future versions.

[ Full documentation | Source code ]


itrcfltr.icn: Program to filter trace output

This program filters trace output.  If there are command-line arguments,
they are taken as procedure names, and only those lines with those
names are written.  If there are no command-line arguments, all lines
are written.

The names of procedures to pass through can be given in a "response"
file as accepted by options(), as in

     itrcfltr @names <trace_file

where names is a file containing the names to be passed through.

The following option is supported:

     -a      list all trace messages; overrides any procedure names
               given

[ Full documentation | Source code ]


itrcsum.icn: Program to give summary of trace output

This program provides a summary of Icon trace output.

[ Full documentation | Source code ]


iundecl.icn: Program to find undeclared Icon identifiers

This program invokes icont to find undeclared variables in an Icon
source program.  The output is in the form of a "local" declaration,
preceded by a comment line that identifies that procedure and file
name from whence it arose.  Beware that undeclared variables aren't
necessarily local, so any which are intended to be global must be
removed from the generated list.

Multiple files can be specified as arguments, and will be processed
in sequence.  A file name of "-" represents the standard input file.
If there are no arguments, standard input is processed.

The program works only if procedures are formatted such that the
keywords "procedure" and "end" are the first words on their
respective lines.

Only for UNIX, since the "p" (pipe) option of open() is used.

[ Full documentation | Source code ]


iversion.icn: Program to show icode version

  This program reports the version of Icon icode files whose names
are supplied, one name per line, from standard input.

  The method is necessarily somewhat heuristic and may not work on
all systems and for very old icode versions.

   This program does not work on icode files with shell headers
(notably Version 9 Icon under UNIX).

[ Full documentation | Source code ]


iwriter.icn: Program to write Icon code to write input

   Program that reads standard input and produces Icon expressions,
which when compiled and executed, write out the original input.

   This is handy for incorporating, for example, message text in
Icon programs.  Or even for writing Icon programs that write Icon
programs that ... .

[ Full documentation | Source code ]


knapsack.icn: Program to fill a container

This filter solves a knapsack problem - how to fill a container to
capacity by inserting items of various volumes.

 input:       a string of newline-separated volumes

 argument:    the capacity to be filled exactly

 output:      a single solution

It is derived from fillup.icn, which has a bewildering array of
options to make it applicable to real-world problems.  In
contrast, knapsack is merely a demonstration of the underlying
algorithm.

The return statement in trynext() greatly improves the efficiency
by restricting the search to fruitful branches of the search tree.
While the use of multiple returns may be considered poor style,
such a structure is often more readable than the alternatives.  In
this case, it also seems to be faster.

 Knapsack may be tested conveniently by piping to it the output
 of randi, a trivial program, like this:

 iconx randi 100 10 | iconx knapsack 250

 You may pick a different capacity, of course; this one just
 happens to produce a result quite quickly, as you might expect.

[ Full documentation | Source code ]


krieg.icn: Program to play kriegspiel

Kriegspiel (German for "war game") implements a monitor and, if desired,
an automatic opponent for a variation of the game of chess which has the
same rules and goal as ordinary chess except that neither player sees
the other's moves or pieces.  Thus Kriegspiel combines the intricacies
and flavor of chess with additional elements of uncertainty, psychology,
subterfuge, etc., which characterize games of imperfect information such
as bridge or poker.

[ Full documentation | Source code ]


kross.icn: Program to show intersections of strings

   This program procedure accepts pairs of strings on successive lines.
It diagrams all the intersections of the two strings in a common
character.

[ Full documentation | Source code ]


kwic.icn: Program to produce keywords in context

   This is a simple keyword-in-context (KWIC) program. It reads from
standard input and writes to standard output. The "key" words are
aligned in column 40, with the text shifted as necessary. Text shifted
left is truncated at the left. Tabs and other characters whose "print width"
is less than one may not be handled properly.

   If an integer is given on the command line, it overrides the default
40.

   Some noise words are omitted (see "exceptions" in the program text).
If a file named except.wrd is open and readable in the current directory,
the words in it are used instead.

   This program is pretty simple.  Possible extensions include ways
of specifying words to be omitted, more flexible output formatting, and
so on.  Another "embellisher's delight".

[ Full documentation | Source code ]


kwicprep.icn: Program to prepare information for IPL KWIC listings

This program prepares information used for creating keyword-in-context
listings of the Icon program library.

[ Full documentation | Source code ]


la.icn: Program to give exponent approximation for large numbers


[ Full documentation | Source code ]


labels.icn: Program to format mailing labels

   This program produces labels using coded information taken
from the input file.  In the input file, a line beginning with #
is a label header.  Subsequent lines up to the next header or
end-of-file are accumulated and output so as to be centered hor-
izontally and vertically on label forms.  Lines beginning with *
are treated as comments and are ignored.

Options: The following options are available:

     -c n Print n copies of each label.

     -s s Select only those labels whose headers contain a char-
          acter in s.

     -t   Format for curved tape labels (the default is to format
          for rectangular mailing labels).

     -w n Limit line width to n characters. The default width is
          40.

     -l n Limit the number of printed lines per label to n. The
          default is 8.

     -d n Limit the depth of the label to n. The default is 9 for
          rectangular labels and 12 for tape labels (-t).

   Options are processed from left to right.  If the number of
printed lines is set to a value that exceeds the depth of the
label, the depth is set to the number of lines.  If the depth is
set to a value that is less than the number of printed lines, the
number of printed lines is set to the depth. Note that the order
in which these options are specified may affect the results.

Printing Labels: Label forms should be used with a pin-feed pla-
ten.  For mailing labels, the carriage should be adjusted so that
the first character is printed at the leftmost position on the
label and so that the first line of the output is printed on the
topmost line of the label.  For curved tape labels, some experi-
mentation may be required to get the text positioned properly.

Diagnostics: If the limits on line width or the number of lines
per label are exceeded, a label with an error message is written
to standard error output.

[ Full documentation | Source code ]


lam.icn: Program to laminate files

   This program laminates files named on the command line onto
the standard output, producing a concatenation of corresponding
lines from each file named.  If the files are different lengths,
empty lines are substituted for missing lines in the shorter
files.  A command line argument of the form - s causes the string
s to be inserted between the concatenated file lines.

   Each command line argument is placed in the output line at the
point that it appears in the argument list.  For example, lines
from file1 and file2 can be laminated with a colon between each
line from file1 and the corresponding line from file2 by the com-
mand

        lam file1 -: file2

   File names and strings may appear in any order in the argument
list.  If - is given for a file name, standard input is read at
that point.  If a file is named more than once, each of its lines
will be duplicated on the output line, except that if standard
input is named more than once, its lines will be read alter-
nately.  For example, each pair of lines from standard input can
be joined onto one line with a space between them by the command

        lam - "- " -

while the command

        lam file1 "- " file1

replicates each line from file1.

[ Full documentation | Source code ]


latexidx.icn: Program to process LaTeX idx file

 Input:

    A latex .idx file containing the \indexentry lines.

 Output:

    \item lines sorted in order by entry value,
 with page references put into sorted order.

Processing:

    While lines are available from standard input
        Read a line containing an \indexentry
        Form a sort key for the indexentry
        If there is no table entry for it
        Then create a subtable for it and assign it an initial value
        If there is a table entry for it,
        But not an subtable entry for the actual indexentry
        Then create an initial page number set for it
        Otherwise add the page number to the corresponding page number set
   Sort the table of subtables by sort key value
   For all subtables in the sorted list
        Sort the subtables by indexentry values
        For all the indexentries in the resulting list
            Sort the set of page references
            Write an \item entry for each indexentry and the page references

 Limitations:

    Length of index handled depends on implementation limits of memory alloc.
 Page numbers must be integers (no roman numerals).  Sort key formed by
 mapping to lower case and removing leading articles (a separate function
 is used to produce the sort key, simplifying customization) -- otherwise
 sorting is done in ASCII order.

[ Full documentation | Source code ]


lc.icn: Program to count lines in file

This program simply counts the number of lines in standard input
and writes the result to standard output.

Assumes UNIX-style line terminators.

Requires lots of memory as written.

[ Full documentation | Source code ]


lcfile.icn: Program to convert file names to lowercase

This program converts file names to lowercase letters.  File names to
convert are given in standard input.

[ Full documentation | Source code ]


lcn.icn: Program to convert file names to all lowercase

This program converts files named on the command line to all lowercase
names.  Blanks are converted to underscores.

[ Full documentation | Source code ]


limitf.icn: Program to limit throughput

This program is intended to be used in a pipe line.  It passes through
at most the number of line given by the command-line option -l (default
10).

[ Full documentation | Source code ]


lindcode.icn: Program to produce Icon code from L-system specifications

This program reads a file of L-system specifications and build Icon
code that creates a table of records containing the specifications.

If the option -e is given, symbols for which there is no definition
are included in the table with themselves as replacement.

[ Full documentation | Source code ]


lindsys.icn: Program to generate sentences in 0L-systems

This program reads in a 0L-system (Lindenmayer system) consisting of
rewriting rules in which a string is rewritten with every character
replaced simultaneously (conceptually) by a specified string of
symbols.

Rules have the form

     S->SSS...

where S is a character.

In addition to rules, there are keywords that describe attributes of the
system.  These include the "axiom", the string on which rewriting is
started and "gener", the number of generations.

The keyword "name" may be used to identify different L-systems in
a file.  If a name is given, it must be the first line of the L-system.

If the keyword "end" is present, it is taken as the termination of
the grammar.  Otherwise, the end of the file serves this purpose.

Other keywords may be present, but are ignored.  For example,

     comment:This produces a great tree.

is ignored.

Keywords are followed by a colon.

  An example 0L-system is:

     name:dragon
     X->-FX++FY-
     Y->+FX--FY+
     F->
     -->-
     +->+
     axiom:FX

Here, the initial string is "FX".

Note that "-" is a legal character in a 0L-system -- context determines
whether it's 0L character or part of the "->" that stands for "is
replaced by".

If no rule is provided for a character, the character is not changed
by rewriting. Thus, the example above can be expressed more concisely
as

     name:dragon
     X->-FX++FY-
     Y->+FX--FY+
     F->
     axiom:FX

The file containing the 0L-system is read from standard input.

The command-line options are:

     -g i    number of generations if not given, default 3
     -a s    axiom (overrides axiom given in the grammar)
     -A      generate all intermediate results, not just the last

Note:  An earlier version of this program had the ability to
extract an L-System specification by name from a file with
multiple specifications.  This version does not -- the former
functionality was deemed too cumbersome.

References:

   Formal Languages, Arto Salomaa, Academic Press, 1973. pp. 234-252.

   The Algorithmic Beauty of Plants, Przemyslaw Prusinkiewicz and
   Aristid Lindenmayer, Springer Verlag, 1990.

   Lindenmayer Systems, Fractals, and Plants, Przemyslaw Prusinkiewicz
   and James Hanan, Springer Verlag, 1989.

[ Full documentation | Source code ]


lineseq.icn: Program to write a sequence of values on a line

This program reads values on separate lines and strings them together
on a single line.  The default separator is a blank; other separating
strings can be specified by the -s option

[ Full documentation | Source code ]


link2url.icn: Program to convert links to URLs

This program takes HTML links from standard input, strips off the
tags and related material, and write the resulting URLs to standard
output.

[ Full documentation | Source code ]


lisp.icn: Program to interpret LISP programs

   This program is a simple interpreter for pure Lisp. It takes the
name of the Lisp program as a command-line argument.

   The syntax and semantics are based on EV-LISP, as described in
Laurent Siklossy's "Let's Talk LISP" (Prentice-Hall, 1976, ISBN
0-13-532762-8).  Functions that have been predefined match those
described in Chapters 1-4 of the book.

   No attempt at improving efficiency has been made, this is
rather an example of how a simple LISP interpreter might be
implemented in Icon.

   The language implemented is case-insensitive.

   It only reads enough input lines at one time to produce at least
one LISP-expression, but continues to read input until a valid
LISP-expression is found.

   It first reads in files listed on command line, switches
to reading standard input, and terminates with the first (exit)
instruction.

Errors:

   Fails with error message if current input cannot be made into
a valid LISP-expression (i.e. more right than left parens).

See HELP function at end of file for syntax summary/examples.

[ Full documentation | Source code ]


lister.icn: Program to list filess

This program lists files.  Note that the language is in Italian.

[ Full documentation | Source code ]


listhtml.icn: Program to create Web page with links to listed files

The files to be included are listed in standard input.  There is no
check that the files actually exist.

[ Full documentation | Source code ]


listviz.icn: Program to visualize lists

This program visualizes lists.  Note that the language is Italian.

[ Full documentation | Source code ]


literat.icn: Program to manage literature information

Database system to manage information concerning literature.

[ Full documentation | Source code ]


ll.icn: Program to list shortest and longest lines in a file

This program reads a file from standard input and writes out the
lengths of the shortest and longest lines in it.

[ Full documentation | Source code ]


loadmap.icn: Program to show load map of UNIX object file

   This program produces a formatted listing of selected symbol classes
from a compiled file.  The listing is by class, and gives the
name, starting address, and length of the region associated with
each symbol.

   The options are:

     -a Display the absolute symbols.

     -b Display the BSS segment symbols.

     -c Display the common segment symbols.

     -d Display the data segment symbols.

     -t Display the text segment symbols.

     -u Display the undefined symbols.

If no options are specified, -t is assumed.

If the address of a symbol cannot be determined, ???? is given in
its place.

[ Full documentation | Source code ]


longest.icn: Program to write longest line in a file

This program writes the (last) longest line in the input file.  If the
command-line option -# is given, the number of the longest line is
written first.

[ Full documentation | Source code ]


lower.icn: Program to map file names to lowercase

This program maps the names of all files in the current directory to
lowercase.

[ Full documentation | Source code ]


lssum.icn: Program to sum the file sizes in an ls -l listing

This program summarizes file sizes give by the UNIX ls -l command.

It probably platform dependent.

[ Full documentation | Source code ]


lsysmap.icn: Program to map L-system symbols

This program maps the symbols in L-Systems.

The following options are supported:

     -i s    input symbols for mapping; default &ucase
     -o s    output symbols for mapping; default &ucase
     -a      put symbols for axiom production in alphabetical
               order (ignores -i and -o)

symbol strings are given on the command line, as in

     lsysmap -i ABCD -o DCBA <exam.lys

There is little error checking.  It's possible to produce an invalid
L-system by creating duplicate nonterminals or changing metacharacters.

The program handles two-level grammars using the first axiom symbol.

[ Full documentation | Source code ]


maccvt.icn: Program to convert Macintosh special characters to ASCII

This program maps the Macintosh characters for quotation and various
minus signs into their ASCII equivalents.

[ Full documentation | Source code ]


makepuzz.icn: Program to make find-the-word puzzle

   This program doesn't do anything fancy.  It simply takes a list
of words, and constructs out of them one of those square
find-the-word puzzles that some people like to bend their minds
over.  Usage is:

    makepuzz [-f input-file] [-o output-file] [-h puzzle-height]
       -w puzzle-width] [-t how-many-seconds-to-keep-trying]
       [-r maximum-number-of-rejects] [-s] [-d]

where input-file is a file containing words, one to a line
(defaults to &input), and output-file is the file you would like the
puzzle written to (defaults to &output).  Puzzle-height and width
are the basic dimensions you want to try to fit your word game into
(default 20x20).  If the -s argument is present, makepuzz will
scramble its output, by putting random letters in all the blank
spaces.  The -t tells the computer when to give up, and construct
the puzzle (letting you know if any words didn't make it in).
Defaults to 60 (i.e. one minute).  The -r argument tells makepuzz to
run until it arrives at a solution with number-of-rejects or less
un-inserted words.  -d turns on certain diagnostic messages.

    Most of these options can safely be ignored.  Just type
something like "makepuzz -f wordlist," where wordlist is a file
containing about sixty words, one word to a line.  Out will pop a
"word-find" puzzle.  Once you get the hang of what is going on,
try out the various options.

    The algorithm used here is a combination of random insertions
and mindless, brute-force iterations through possible insertion
points and insertion directions.  If you don't like makepuzz's per-
formance on one run, run it again.  If your puzzle is large, try
increasing the timeout value (see -t above).

[ Full documentation | Source code ]


mapcolrs.icn: Program to map colors in lists

This program maps colors in lists.

This is a work in progress.

[ Full documentation | Source code ]


midisig.icn: Program to show signature of a MIDI file

This program displays the signature of a MIDI file.

[ Full documentation | Source code ]


missile.icn: Program to play missile command game

Here is a cheap attempt at a Missile Command game.

I've run it under Icon V8.7 under VMS, Unix, and V8.5 under MS-DOS.

Here are some things you'll need to know. There is a delay() procedure
that keeps the game running at a steady pace. delay() is built into
V8.7 on VMS and unix. Under DOS you'll need to roll your own.
The program also uses ansi escape sequences. Also to play use 7, 8, and 9
to launch a # missile. 7 is leftward, 8 is straight, and 9 is right. A bug
in the Ultrix version (kbhit() and getch()) requires double pressing the
buttons. I think q will quit the game early.

Have Fun!

[ Full documentation | Source code ]


miu.icn: Program to generate strings from MIU system

   This program generates strings from the MIU string system.

   The number of generations is determined by the command-line argument.
The default is 7.

Reference:

   Godel, Escher, and Bach: an Eternal Golden Braid, Douglas R.
Hofstadter, Basic Books, 1979. pp. 33-36.

[ Full documentation | Source code ]


mkpasswd.icn: Program to make passwords

This program creates a list of randomly generated passwords.

Passwords consist of eight random characters [A-Z][0-9].

Number of passwords to generate is given as the first argument; default 1.

[ Full documentation | Source code ]


monkeys.icn: Program to generate random text

The old monkeys at the typewriters anecdote ...

   This program uses ngram analysis to randomly generate text in
the same 'style' as the input text.  The arguments are:

   -s     show the input text
   -n n   use n as the ngram size (default:3)
   -l n   output at about n lines (default:10)
   -r n   set random number seed to n

[ Full documentation | Source code ]


morse.icn: Program to convert string to Morse code

If "morse" is invoked without arguments, a Morse code table is
printed.  If words are entered as arguments, the Morse code
conversion is printed in dots and dashes.  If the first character of
the first argument is a dot or dash, the arguments are takes as Morse
code and converted to a string.

[ Full documentation | Source code ]


mr.icn: Program to read mail

With no arguments, mr reads the default mail spool.  Another user,
a spool file, or the recipient for outgoing mail can be given as
a command line argument.  Help, including the symbols used to
indicate the status of mail, is available with the H command.

Usage:  mr [recipient] [-u user] [-f spool]

Configuration:

  Editor     for replies or new mail.
  Host       optional upstream routing address for outgoing mail;
             a domained Host is appended to the address, a uucp
             Host prefixes the address.
  Mail_cmd   the system mailer (usually sendmail, smail, or mail).
  print_cmd  command to format and/or spool material for the printer
             (for OS with pipes).  &null for ms-dos.
  ignore     a list of headers to hide when paging messages.  The V
             command views hidden headers.

Non-UNIX systems only:

  non_unix_mailspool  full path of the default mailspool.

[ Full documentation | Source code ]


mszip.icn: Program to ZIP a directory for MS-DOS use

usage:  mszip [options] root-directory zip-file
     -n      no action: just report; zip-file may be omitted
     -v      verbose commentary: list individual file types
     -i      check filenames for ISO 9660 (CD-ROM) legality

Mszip stuffs the contents of a directory into a ZIP archive file,
translating text files to CRLF form.  Pipes are opened that
require find, sort, and zip in the search path.

The default report gives an inventory of files by extension.  This
can be useful even without creating a ZIP file ("mszip -n dir").

File types on the verbose report are:
     x       unreadable file
     e       empty file
     b       binary file
     c       text file with CRLFs
     n       text file with newlines
A file is "binary" if it contains more than 1% unexpected characters.

Symlinks, FIFOs, device files etc. are reported and not archived.
Files with illegal MS-DOS names are reported but still archived.

[ Full documentation | Source code ]


mtf3.icn: Program to map tar file

PURPOSE: Maps 15+ char. filenames in a tar archive to 14 chars.
Handles both header blocks and the archive itself.  Mtf is intended
to facilitate installation of tar'd archives on systems subject to
the System V 14-character filename limit.

USAGE:  mtf inputfile [-r reportfile] [-e .extensions] [-x exceptions]

"Inputfile" is a tar archive.  "Reportfile" is file containing a
list of files already mapped by mtf in a previous run (used to
avoid clashes with filenames in use outside the current archive).
The -e switch precedes a list of filename .extensions which mtf is
supposed to leave unscathed by the mapping process
(single-character extensions such as .c and .o are automatically
preserved; -e allows the user to specify additional extensions,
such as .pxl, .cpi, and .icn).  The final switch, -x, precedes a
list of strings which should not be mapped at all.  Use this switch
if, say, you have a C file with a structure.field combination such
as "thisisveryverybig.hashptr" in an archive that contains a file
called "thisisveryverybig.h," and you want to avoid mapping that
portion of the struct name which matches the name of the overlong
file (to wit, "mtf inputfile -x thisisveryverybig.hashptr").  To
prevent mapping of any string (including overlong filenames) begin-
ning, say, with "thisisvery," use "mtf inputfile -x thisisvery."
Be careful with this option, or you might end up defeating the
whole point of using mtf in the first place.

OUTPUT FORMAT:  Mtf writes a mapped tar archive to the stdout.
When finished, it leaves a file called "map.report" in the current
directory which records what filenames were mapped and how.  Rename
and save this file, and use it as the "reportfile" argument to any
subsequent runs of mtf in this same directory.  Even if you don't
plan to run mtf again, this file should still be examined, just to
be sure that the new filenames are acceptable, and to see if
perhaps additional .extensions and/or exceptions should be
specified.

BUGS:  Mtf only maps filenames found in the main tar headers.
Because of this, mtf cannot accept nested tar archives.  If you try
to map a tar archive within a tar file, mtf will abort with a nasty
message about screwing up your files.  Please note that, unless you
give mtf a "reportfile" to consider, it knows nothing about files
existing outside the archive.  Hence, if an input archive refers to
an overlong filename in another archive, mtf naturally will not
know to shorten it.  Mtf will, in fact, have no way of knowing that
it is a filename, and not, say, an identifier in a C program.
Final word of caution:  Try not to use mtf on binaries.  It cannot
possibly preserve the correct format and alignment of strings in an
executable.  Same goes for compressed files.  Mtf can't map
filenames that it can't read!

[ Full documentation | Source code ]


newicon.icn: Program to produce new Icon program file

This program creates a new file with a standard Icon program
header and a skeleton mail procedure.

The first command-line argument is taken as the base
name of the file; default "foo".  The second command-line argument is
taken as the author; the default is "Ralph E. Griswold" -- with minor
apologies, I use this program a lot; personalize it for your own
use.  The same comment applies to the skeleton file mentioned below.

The new file is brought up in the vi editor.

The supported options are:

     -f      overwrite and existing file
     -p      produce a procedure file instead of a program
     -o      provide program skeleton with options()

The files skeleton.icn, skelproc.icn, and skelopt.icn must be accessible
via dopen().

[ Full documentation | Source code ]


newsrc.icn: Program to organize UNIX .newsrc file

This program takes the .newsrc file, moves active groups to the beginning
then appends inactive groups with the numbers omitted, then anything else.
the groups are alphabetized.

The user may retain a set of groups at the top of the file by specifying how
many groups on the command line. If not specified, it will be prompted for.
the new file is called newnewsrc. The user can replace .newsrc with it if it
is satisfactory.

[ Full documentation | Source code ]


nim.icn: Program to play the game of nim

The game of nim focuses on a pile of 15 sticks.  Each player can
select 1, 2, or 3 sticks from the sticks remaining in the pile when
it's their turn.  The player to pick up the last stick(s) wins.  The
loser of the previous game always gets to go first.

There are two versions of nim in here.  The first (default) version
uses an algorithm to make its moves.  It will never lose if it gets
the first turn.  The second version tries to learn from each game.
You'll have to play a few games before it will get very smart but
after a while it will also never lose if it gets the first turn.  This
is assuming of course that you know how to play.  Since the learning
version learns from the person it plays against, if you're lousy the
game will be too.

To invoke the learning version just pass any argument to the program.
If you want to see how the program learns, you can use the string
"show" as the argument and the program's current game memory will be
displayed after each game.  If you invoke the game with the string save
as an argument a file called ".nimdump" will be created in the current
directory with a dump of the program's game memory when you quit and
the next time the game is played in learn mode it will initialize its
game memory from the dump.  You can invoke this program with more than
one argument so show and save can be used at the same time.

[ Full documentation | Source code ]


nocr.icn: Program to convert MS-DOS text files to UNIX

  This program simply converts \r\n to \n in each line of each of the
files supplied as command-line arguments, thereby effecting conversion
of MS-DOS format text files to the corresponding UNIX format.

     usage:  nocr file1 [file2 [etc.]]

  No check done to see whether the file is in fact a text file.

[ Full documentation | Source code ]


noise.icn: Program to generate random noise

This program generates random 8-bit bytes until killed.
While it may not be cryptographically strong, it is
suitable for overwriting a disk or tape for disposal.

[ Full documentation | Source code ]


normalize.icn: Program to normalize numeric channel

This program reads numbers, one per line, from standard input and
writes them out normalized so that the largest is 1.0.

[ Full documentation | Source code ]


oldicon.icn: Program to update the date in an Icon program header

This program updates the date line in a standard Icon program header.
The old file is saved with the suffix ".bak".

The file then is brought up in the vi editor unless the -f option
is specified.

[ Full documentation | Source code ]


pack.icn: Program to package multiple files

   This programs takes a list of file names on the command line and
packages the files into a single file, which is written to standard
output.

   Files are separated by a header, ##########, followed by the file
name.  This simple scheme does not work if a file contains such a header
itself, and it's problematical for files of binary data.

[ Full documentation | Source code ]


paginate.icn: Program to insert formfeeds

This program processes a document text file, inserting formfeeds
at appropriate places.

[ Full documentation | Source code ]


papply.icn: Program to apply procedure to lines of file

This program applies the procedure given as a command-line argument
to each line of standard input, writing out the results.  For example,

     papply reverse <foo

writes out the lines of foo reversed end-for-end.

As it stands, there is no way to provide other arguments.  That' easy
to remedy.

Except for use with (built-in) functions, this program needs to be linked
with procedures that might be used with it.

[ Full documentation | Source code ]


parens.icn: Program to produce random balanced strings

   This program produces parenthesis-balanced strings in which
the parentheses are randomly distributed.

Options: The following options are available:

     -b n Bound the length of the strings to n left and right
          parentheses each. The default is 10.

     -n n Produce n strings. The default is 10.

     -l s Use the string s for the left parenthesis. The default
          is ( .

     -r s Use the string s for the right parenthesis. The default
          is ) .

     -v   Randomly vary the length of the strings between 0 and
          the bound.  In the absence of this option, all strings
          are the exactly as long as the specified bound.

   For example, the output for

        parens -v -b 4 -l "begin " -r "end "

is

        begin end
        begin end begin end
        begin begin end end begin end
        begin end begin begin end end
        begin end
        begin begin end end
        begin begin begin end end end
        begin end begin begin end end
        begin end begin end
        begin begin end begin end begin end end


Comments: This program was motivated by the need for test data
for error repair schemes for block-structured programming lan-
guages. A useful extension to this program would be some
way of generating other text among the parentheses.  In addition
to the intended use of the program, it can produce a variety of
interesting patterns, depending on the strings specified by -l
and -r.

[ Full documentation | Source code ]


pargen.icn: Program to generate context-free parser

   This program reads a context-free BNF grammar and produces an Icon
program that is a parser for the corresponding language.

   Nonterminal symbols are are enclosed in angular brackets. Vertical
bars separate alternatives.  All other characters are considered to
be terminal symbols.  The nonterminal symbol on the first line is
taken to be the goal.

   An example is:

     <expression>::=<term>|<term>+<expression>
     <term>::=<element>|<element>*<term>
     <element>::=x|y|z|{<expression>}

   Parentheses can be used for grouping symbols, as in

     <term>::=<element>(|*<term>)

   Note that an empty alternative is allowable.

   The right-hand side metacharacters <, >, (, ), and | are accessible
through the built-in symbols <lb>, <rb>, <lp>, <rp>, and <vb>,
respectively. There are two other build-in symbols, <empty> and <nl>
that match the empty string and a newline, respectively.

   Characters in nonterminal names are limited to letters, digits, and
underscores.

   An underscore is appended to the parsing procedure name to avoid
possible collisions with Icon function names.

   Lines beginning with an = are passed through unchanged. This allows
Icon declarations to be placed in the parser.  Lines beginning with
a # are considered to be comments and are ignored.

   If the name of a ucode file is given on the command line, a link
declaration for it is provided in the output. Otherwise the main
procedure in recog is used.

[ Full documentation | Source code ]


parse.icn: Program to parse simple statements

This program parses simple statements.

It provides an interesting example of the use of co-expressions.

[ Full documentation | Source code ]


parsex.icn: Program to parse arithmetic expressions

 Adapted from C code written by Allen I. Holub published in the
 Feb 1987 issue of Dr. Dobb's Journal.

 General purpose expression analyzer.  Can evaluate any expression
 consisting of number and the following operators (listed according
 to precedence level):

 () - ! 'str'str'
 * / &
 + -
 < <= > >= == !=
 && ||

All operators associate left to right unless () are present.
The top - is a unary minus.


 <expr>   ::= <term> <expr1>
 <expr1>  ::= && <term> <expr1>
          ::= || <term> <expr1>
          ::= epsilon

 <term>   ::= <fact> <term1>
 <term1>  ::= <  <fact> <term1>
          ::= <= <fact> <term1>
          ::= >  <fact> <term1>
          ::= >= <fact> <term1>
          ::= == <fact> <term1>
          ::= != <fact> <term1>
          ::= epsilon

 <fact>   ::= <part> <fact1>
 <fact1>  ::= + <part> <fact1>
          ::= - <part> <fact1>
          ::= - <part> <fact1>
          ::= epsilon

 <part>   ::= <const> <part1>
 <part1>  ::= * <const> <part1>
          ::= / <const> <part1>
          ::= % <const> <part1>
          ::= epsilon

 <const>  ::= ( <expr> )
          ::= - ( <expr> )
          ::= - <const>
          ::= ! <const>
          ::= 's1's2'    # compares s1 with s2  0 if ~= else 1
          ::= NUMBER     # number is a lose term any('0123456789.Ee')

[ Full documentation | Source code ]


patchu.icn: Program to implement UNIX-like patch

This program reads a source file and a diff file, producing an
updated file.  The diff file may be generated by the UNIX diff(1)
utility, or by diffu.icn, which uses dif.icn for the hard work.

The original patch(1) utility, written by Larry Wall, is widely
used in the UNIX community.

The diff file contains edit lines, separators, and text lines.
Edit lines may take the forms:

     #a#[,#]                 <- add    lines
     #[,#]c#[,#]             <- change lines
     #[,#]d#                 <- delete lines

Change lines contain only the string "---".  All other lines are
text lines.  See diff(1) in any UNIX manual for more details.

[ Full documentation | Source code ]


pbkdump.icn: Program to dump HP95 phone book file

Program to dump data from a HP95 phone book (pbk) file.

[ Full documentation | Source code ]


pdecomp.icn: Program to list primes factors of an integer

This program lists the prime factors of integers given in
standard input.

[ Full documentation | Source code ]


polydemo.icn: Program to demonstrate polynomial library

    This program is an example for the use of the polystuf library.  The
user is given a number of options that allow the creation, output,
deletion, or operations on up to 26 polynomials, indexed by letter.

Available commands:
    (R)ead      - allows input of a polynomial by giving pairs of
                  coefficients and exponents.  For example, entering
                  5, 6, 2, and 3 will create 5x^6 + 2x^3.  This polynomial
                  will be stored by an index which is a lower-case letter.
    (W)rite     - outputs to the screen a chosen polynomial.
    (A)dd       - adds two polynomials and defines the sum as a third
    (S)ubtract  - subtracts two polynomials and defines the difference as
                  a third.
    (M)ultiply  - multiplies two polynomials and defines the product as a
                  third.
    (E)valuate  - gives the result of setting x in a polynomial to a value
    (C)lear     - deletes one polynomial
    (H)elp      - lists all commands
    (Q)uit      - end the demonstration

[ Full documentation | Source code ]


post.icn: Program to post news

This program posts a news article to Usenet.  Given an optional
argument of the name of a file containing a news article, or an
argument of "-" and a news article via stdin, post creates a
follow-up article, with an attribution and quoted text.  The
newsgroups, subject, distribution, follow-up, and quote-prefix can
optionally be specified on the command line.

    usage: post [options] [article | -]
             -n newsgroups
             -s subject
             -d distribution
             -f followup-to
             -p quote-prefix (default ` > ')

See the site & system configuration options below.  On systems
posting via inews, post validates newsgroups and distributions in
the `active' and `distributions' files in the news library directory.

[ Full documentation | Source code ]


press.icn: Program to archive files

Besides being a useful file archiving utility, this program can be
used to experiment with the LZW compression process, as it contains
extensive tracing facilities that illustrate the process in detail.

Compression can be turned off if faster archiving is desired.

The LZW compression procedures in this program are general purpose
and suitable for reuse in other programs.

[ Full documentation | Source code ]


pretrim.icn: Program to filter out first terms in an input stream

This program discards the first i values in input, given by -n i; default
0.

[ Full documentation | Source code ]


procprep.icn: Program to produce input to index for procedure comments

This program is used to produce the data needed to index the "#:"
comments on procedure declarations that is needed to produces a
permuted index to procedures.

[ Full documentation | Source code ]


procwrap.icn: Program to produce Icon procedure wrappers

This little program takes procedure names from standard input and
writes minimal procedure declarations for them.  For example, the
input line

     wrapper

produces

     procedure wrapper()
     end

This program is useful when you have a lot of procedures to write.

[ Full documentation | Source code ]


proto.icn: Program to show Icon syntactic forms

   This program doesn't "do" anything.  It just contains an example of
every syntactic form in Version 7 of Icon (or close to it).  It might
be useful for checking programs that process Icon programs.  Note, however,
that it does not contain many combinations of different syntactic forms.

[ Full documentation | Source code ]


psrsplit.icn: Program to separate psrecord.icn output pages

usage:  psrsplit file

   If a file produced by the procedures in psrecord.icn contains multiple
pages, it cannot be easily incorporated into another document.  psrsplit
reads such a file and breaks it into individual pages.  The algorithm
is frugal of memory and file descriptors at the expense of reading the
input file multiple times.

   For an input file is named xxxx or xxxx.yyy, the output files are
named xxxx.p01, xxxx.p02, etc. for as many pages as are available.
It is assumed that the input file was written by psrecord.icn; the
likelihood of correctly processing anything else is small.

[ Full documentation | Source code ]


pt.icn: Program to produce parse table generator

See pt.man for a description of functionality as well as input and
output format.

[ Full documentation | Source code ]


puzz.icn: Program to create word search puzzle

This program creates word search puzzles.

[ Full documentation | Source code ]


qei.icn: Program to evaluate Icon expressions interactively

This program takes expressions entered at the command line and
evaluates them.

A semicolon is required to complete an expression.  If one is not
provided, the subsequent line is added to what already has been
entered.

It is important to know that qei accumulates expressions and evaluates
all previously entered expressions before it evaluates a new one.

A line beginning with a colon is a command.  The commands are:


     :clear          clear the accumulated expressions.

     :every          generate all the results from the expression;
                     otherwise, at most one is produced.

     :exit           terminate the session
     :quit           terminate the session

     :list           list the accumulated expressions.

     :type           toggle switch that displays the type of the
                     result; the program starts with this switch on.

[ Full documentation | Source code ]


qt.icn: Program to announce time in English

Usage: qt [-a]

If -a is present, only the time is printed (for use in scripts), e.g.:

     just after a quarter to three

otherwise, the time is printed as a sentence:

     It's just after a quarter to three.

[ Full documentation | Source code ]


queens.icn: Program to generate solutions to the n-queens problem

   This program displays the solutions to the non-attacking n-
queens problem: the ways in which n queens can be placed on an
n-by-n chessboard so that no queen can attack another. A positive
integer can be given as a command line argument to specify the
number of queens. For example,

        iconx queens -n8

displays the solutions for 8 queens on an 8-by-8 chessboard.  The
default value in the absence of an argument is 6.  One solution
for six queens is:

       -------------------------
       |   | Q |   |   |   |   |
       -------------------------
       |   |   |   | Q |   |   |
       -------------------------
       |   |   |   |   |   | Q |
       -------------------------
       | Q |   |   |   |   |   |
       -------------------------
       |   |   | Q |   |   |   |
       -------------------------
       |   |   |   |   | Q |   |
       -------------------------

Comments: There are many approaches to programming solutions to
the n-queens problem.  This program is worth reading for
its programming techniques.

[ Full documentation | Source code ]


ranstars.icn: Program to display star field

   This program display a random field of "stars" on an ANSI terminal.
It displays stars at randomly chosen positions on the screen until
the specified maximum number is reached. It then extinguishes existing
stars and creates new ones for the specified steady-state time, after
which the stars are extinguished, one by one.

   The programming technique is worth noting. It is originally due to
Steve Wampler.

   The options are:

     -m n    maximum number of stars, default 10.

     -t n    length of steady-state time before stars are extinguished,
               default 50.

     -s c    the character to be used for "stars", default *. If
               more than one character is given, only the first is
               used.

[ Full documentation | Source code ]


rcat.icn: Program to output a file from back to front

This program outputs in reverse order the lines of one or more files.
Unlike some versions of "tail -r", the input file does not need to
fit in memory; but it must be seekable.

usage:  rcat file...

[ Full documentation | Source code ]


recgen.icn: Program to generate context-free recognizer

   This program reads a context-free BNF grammar and produces an Icon
program that is a recognizer for the corresponding language.

   Nonterminal symbols are are enclosed in angular brackets. Vertical
bars separate alternatives.  All other characters are considered to
be terminal symbols.  The nonterminal symbol on the first line is
taken to be the goal.

   An example is:

     <expression>::=<term>|<term>+<expression>
     <term>::=<element>|<element>*<term>
     <element>::=x|y|z|(<expression>)

   Characters in nonterminal names are limited to letters and underscores.
An underscore is appended for the recognizing procedure name to avoid
possible collisions with Icon function names.

   Lines beginning with an = are passed through unchanged. This allows
Icon code to be placed in the recognizer.

[ Full documentation | Source code ]


repeats.icn: Program to repeat stream

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.

[ Full documentation | Source code ]


reply.icn: Program to reply to news-articles or mail

This program creates the appropriate headers and attribution,
quotes a news or mail message, and uses system() calls to put the
user in an editor and then to mail the reply.  The default prefix
for quoted text is ` > '.

    usage: reply [prefix] < news-article or mail-item

If a smarthost is defined, Internet addresses are converted to bang
paths (name@site.domain -> site.domain!name).  The mail is routed
to a domained smarthost as address@smarthost.domain, otherwise to
smarthost!address.

The default editor can be overridden with the EDITOR environment variable.

[ Full documentation | Source code ]


repro.icn: Program to self-reproduce

This program generates the shortest known self-reproducing Icon
program.  The generated program is identical to this file except
for deletion of this header and the "global x" declaration, which
appear here so that the Icon library builds cleanly.

[ Full documentation | Source code ]


revfile.icn: Program to reverse the order of lines in a file

This program reverses the order of lines in a file.  Beware of large
files.

[ Full documentation | Source code ]


revsort.icn: Program to sort strings backwards

This program sorts strings with characters in reverse order.

[ Full documentation | Source code ]


roffcmds.icn: Program to list roff commands and macros

   This progam processes standard input and writes a tabulation of
nroff/troff commands and defined strings to standard output.

Limitations:

   This program only recognizes commands that appear at the beginning of
lines and does not attempt to unravel conditional constructions.
Similarly, defined strings buried in disguised form in definitions are
not recognized.

Reference:

   Nroff/Troff User's Manual, Joseph F. Ossana, Bell Laboratories,
Murray Hill, New Jersey. October 11, 1976.

[ Full documentation | Source code ]


rsg.icn: Program to generate randomly selected sentences

   This program generates randomly selected strings (``sen-
tences'') from a grammar specified by the user.  Grammars are
basically context-free and resemble BNF in form, although there
are a number of extensions.

[ Full documentation | Source code ]


ruler.icn: Program to write a character ruler

Write a character ruler to standard output.  The first optional
argument is the length of the ruler in characters (default 80).
The second is a number of lines to write, with a line number on
each line.

[ Full documentation | Source code ]


sample.icn: Program to "sample" input stream

This program filters the input stream, producing every ith
value, starting at 1.  i is given as a command-line argument; default 0.

[ Full documentation | Source code ]


scale.icn: Program to scale numeric values in visualization stream

This program scales the numerical channel of a visualization stream.
It leaves color channel alone, if there is one.  Scale factor is
given on command line; default 10.

Note:  This program can be used on a numerical stream.

[ Full documentation | Source code ]


scramble.icn: Program to scramble a document

This program takes a document and re-outputs it in a cleverly
scrambled fashion. It uses the next two most likely words to
to follow.

The concept was found in a recent Scientific American and Icon
seemed to offer the best implementation.

[ Full documentation | Source code ]


setmerge.icn: Program to combine sets of text items

Setmerge combines sets of items according to the specified operators.
Sets are read from files, one entry per line.  Operation is from left
to right without any precedence rules.  After all operations are
complete the resulting set is sorted and written to standard output.

Usage:  setmerge file [[op] file]...

Operations:
     +  add contents to set
     -  subtract contents from set
     *  intersect contents with set

Note that operators must be separate command options, and that some
shells my require some of them to be quoted.

Example 1: combine files, sorting and eliminating duplicates:

     setmerge file1 + file2 + file3 + file4

Example 2: print lines common to three files

     setmerge file1 '*' file2 '*' file3

Example 3: print lines in file1 or file2 but not in file3

     setmerge file1 + file2 - file3

[ Full documentation | Source code ]


shar.icn: Program to create UNIX shell archive

Program to create Bourne shell archive of text files.

Usage: shar text_file...

[ Full documentation | Source code ]


shortest.icn: Program to write shortest line in a file

This program writes the (last) shortest line in the input file.  If the
command-line option  -# is given, the number of the shortest line is
written first.

[ Full documentation | Source code ]


shuffile.icn: Program to shuffle lines in a file

   This program writes a version of the input file with the lines
shuffled.  For example, the result of shuffling

                 On the Future!-how it tells
                 Of the rapture that impells
                To the swinging and the ringing
                 Of the bells, bells, bells-
              Of the bells, bells, bells, bells,
                        Bells, bells, bells-
          To the rhyming and the chiming of the bells!

is

          To the rhyming and the chiming of the bells!
                To the swinging and the ringing
                        Bells, bells, bells-
                 Of the bells, bells, bells-
                 On the Future!-how it tells
              Of the bells, bells, bells, bells,
                 Of the rapture that impells

The following options are supported:

     -s i    Set random seed to i; default 0
     -r      Set random seed using randomize(); overrides -s

Limitation:

   This program stores the input file in memory and shuffles pointers to
   the lines; there must be enough memory available to store the entire
   file.

[ Full documentation | Source code ]


shuffle.icn: Program to randomly reorder the lines of a file

This program outputs in random order the lines of one or more files.
The input data must fit in memory.

usage:  shuffle [file...]

[ Full documentation | Source code ]


sing.icn: Program to sing The Twelve Days of Christmas

   This program is an Icon adaptation of a SNOBOL program by Mike
Shapiro in the book The SNOBOL4 Programming Language.  The procedure
sing writes the lyrics to the song, "The Twelve Days of Christmas"
to the singer parameter.  "singer" can be any file open for output,
but it would be especially nice to send the lyrics to a speech
synthesiser (perhaps via a pipe).

   The algorithm used can be adapted to other popular songs, such as
"Old McDonald had a Farm".

Reference:

   "The SNOBOL 4 Programming Language" by Griswold, Poage, and
Polonsky, 2nd ed. Englewood Cliffs, N.J. Prentiss-Hall, Inc. 1971.

[ Full documentation | Source code ]


slice.icn: Program to write long line as multiple short lines

The maximum line length is given on the command line, as in

     slice 60 < foo > baz

[ Full documentation | Source code ]


snake.icn: Program to play the snake game

    While away the idle moments watching the snake eat blank squares
on your screen.  Snake has only one (optional) argument -

    usage:  snake [character]

where "character" represents a single character to be used in drawing
the snake.  The default is an "o."  In order to run snake, your ter-
minal must have cursor movement capability, and must be able to do re-
verse video.

    I wrote this program to test itlib.icn, iscreen.icn, and some
miscellaneous utilities I wrote.  It clears the screen, moves the cur-
sor to arbitrary squares on the screen, changes video mode, and in
general exercises the terminal capability database on the target ma-
chine.

[ Full documentation | Source code ]


solit.icn: Program to play solitaire

   This program was inspired by a solitaire game that was written
by Allyn Wade and copyrighted by him in 1985.  His game was
designed for the IBM PC/XT/PCjr with a color or monochrome moni-
tor.

   I didn't follow his design exactly because I didn't want to
restrict myself to a specific machine.  This program has the
correct escape sequences programmed into it to handle several
common terminals and PC's.  It's commented well enough that most
people can modify the source to work for their hardware.

   These variables must be defined with the correct escape
sequences to:

        CLEAR  -  clear the screen
        CLREOL -  clear to the end of line
        NORMAL -  turn on normal video for foreground characters
        RED    -  make the foreground color for characters red
        BLACK  -  make the foreground color for characters black

If there is no way to use red and black, the escape sequences
should at least make RED and BLACK have different video attri-
butes; for example red could have inverse video while black has
normal video.

   There are two other places where the code is device dependent.
One is in the face() procedure.  The characters used to display
the suites of cards can be modified there.  For example, the IBM
PC can display actual card face characters while all other
machines currently use HDSC for hearts, diamonds, spades and
clubs respectively.

   The last, and probably trickiest place is in the movecursor()
procedure.  This procedure must me modified to output the correct
escape sequence to directly position the cursor on the screen.
The comments and 3 examples already in the procedure will help.

   So as not to cast dispersions on Allyn Wade's program, I
incorporated the commands that will let you cheat.  They didn't
exist in his program.  I also incorporated the auto pilot command
that will let the game take over from you at your request and try
to win.  I've run some tests, and the auto pilot can win about
10% of the games it's started from scratch.  Not great but not
too bad.  I can't do much better myself without cheating.  This
program is about as totally commented as you can get so the logic
behind the auto pilot is fairly easy to understand and modify.
It's up to you to make the auto pilot smarter.

[ Full documentation | Source code ]


sortname.icn: Program to order by last name

This program sorts a list of person's names by the last names.

[ Full documentation | Source code ]


splitlit.icn: Program to create string literal

The idea is to create a string literal with continuations in case
it's too long.

The options are:

     -w i    width of piece on line, default 50
     -i i    indent, default 3

[ Full documentation | Source code ]


spread.icn: Program to format tab-separated data columns

Spread reads data presented in tab-separated fields, such
as some some spreadsheets export, and outputs the data in
space-separated columns of the minimum necessary width.

Usage:  spread [-t c] [-g n] [-r] [file...]

-g n    set gutter width between output columns (default is 1)
-r      right-justify the fields instead of left-justifying
-t c    set separator character(s) for data (default is \t)

[ Full documentation | Source code ]


streamer.icn: Program to append lines of file into one long line

This program outputs one long line obtained by concatenating the
lines of the input file.

The supported options are:

     -l i    stop when line reaches or exceeds i; default no limit
     -s s    insert s after each line; default no separator

Separators are counted in the length limit.

[ Full documentation | Source code ]


strimlen.icn: Program to produce lengths of string images

This program is a filter that reads images of Icon strings from standard
input and writes the lengths of the strings to standard output.

[ Full documentation | Source code ]


strpsgml.icn: Program to strip/translate SGML tags

Strip or perform simple translation on SGML <>-style tags.  Usage
is as follows:

    strpsgml [-f translation-file] [left-delimiter [right-delimiter]]

The default left-delimiter is <, the default right delimiter is >.
If no translation file is specified, the program acts as a strip-
per, simply removing material between the delimiters.  Strpsgml
takes its input from stdin, writing to stdout.

The format of the translation file is:

    code     initialization  completion

A tab or colon separates the fields.  If you want to use a tab or colon
as part of the text (and not as a separator), place a backslash before
it.  The completion field is optional.  There is not currently any way
of specifying a completion field without an initialization field.  Do
not specify delimiters as part of code.

Note that, if you are translating SGML code into font change or escape
sequences, you may get unexpected results.  This isn't strpsgml's
fault.  It's just a matter of how your terminal or WP operate.  Some
need to be "reminded" at the beginning of each line what mode or font
is being used.  Note also that stripsgml assumes < and > as delimiters.
If you want to put a greater-than or less-than sign into your text,
put a backslash before it.  This will effectively "escape" the spe-
cial meaning of those symbols.  It is now possible to change the
default delimiters, but the option has not been thoroughly tested.

[ Full documentation | Source code ]


tabexten.icn: Program to tabulate file extensions

This program tabulates the file name extensions -- what follows the
last period in a file name.

It is designed handle output UNIX ls -R, but it will handle a list
of file names, one per line.

[ Full documentation | Source code ]


tablc.icn: Program to tabulate characters in a file

   This program tabulates characters and lists each character and
the number of times it occurs. Characters are written using
Icon's escape conventions.  Line termination characters and other
control characters are included in the tabulation.

Options: The following options are available:

     -a   Write the summary in alphabetical order of the charac-
          ters. This is the default.

     -n   Write the summary in numerical order of the counts.

     -u   Write only the characters that occur just once.

[ Full documentation | Source code ]


tablw.icn: Program to tabulate words in a file

   This program tabulates words and lists number of times each
word occurs. A word is defined to be a string of consecutive
upper- and lowercase letters with at most one interior occurrence
of a dash or apostrophe.

Options: The following options are available:

     -a   Write the summary in alphabetical order of the words.
          This is the default.

     -i   Ignore case distinctions among letters; uppercase
          letters are mapped into to corresponding lowercase
          letters on input. The default is to maintain case dis-
          tinctions.

     -n   Write the summary in numerical order of the counts.

     -l n Tabulate only words longer than n characters. The
          default is to tabulate all words.

     -u   Write only the words that occur just once.

[ Full documentation | Source code ]


tabulate.icn: Program to tabulate lines in a file

This program produces a tabulation showing how many times each
line of a file occurs.

[ Full documentation | Source code ]


textcnt.icn: Program to tabulate properties of text file

   This program tabulates the number of characters, "words", and
lines in standard input and gives the maximum and minimum line length.

[ Full documentation | Source code ]


textcvt.icn: Program to convert text file formats

Program to convert text file(s) among various platforms' formats.

The supported text file types are UNIX, MS-DOS, and Macintosh.  A
universal input text reading algorithm is used, so only the output
file format must be specified.

The files are either converted in-place by converting to a temporary
file and copying the result back to the original, or are copied to a
separate new file, depending on the command line options.  If the
conversion is interrupted, the temporary file might still remain as
<original name>.temp (or, for MS-DOS, <original name root>.tmp.

[ Full documentation | Source code ]


toktab.icn: Program to summarize Icon token counts

This program reads the token files given on the command line and
summarizes them in a single file.

The supported options are:

     -n      sort tokens by category in decreasing numerical order;
                default alphabetical sorting
     -l i    limit output in any category to i items; default no limit

[ Full documentation | Source code ]


trim.icn: Program to trim lines in a file

   This program copies lines from standard input to standard out-
put, truncating the lines at n characters and removing any trail-
ing blanks and tabs. The default value for n is 80.  For example,

        trim 70 <grade.txt >grade.fix

copies grade.txt to grade.fix, with lines longer than 70 charac-
ters truncated to 70 characters and the trailing blanks removed
from all lines.

   The -f option causes all lines to be n characters long by
adding blanks to short lines; otherwise, short lines are left as
is.

[ Full documentation | Source code ]


ttt.icn: Program to play tic-tac-toe

This program plays the game of tic-tac-toe.

[ Full documentation | Source code ]


turing.icn: Program to simulate a Turing machine

   This program simulates the operation of an n-state Turing machine,
tracing all actions.  The machine starts in state 1 with an empty tape.

   A description of the Turing machine is read from the file given as a
command-line argument, or from standard input if none is specified.
Comment lines beginning with '#' are allowed, as are empty lines.

   The program states must be numbered from 1 and must appear in order.
Each appears on a single line in this form:

    sss.  wdnnn  wdnnn

sss is the state number in decimal.  The wdnnn fields specify the
action to be taken on reading a 0 or 1 respectively:

    w   is the digit to write (0 or 1)
    d   is the direction to move (L/l/R/r, or H/h to halt)
    nnn is the next state number (0 if halting)

Sample input file:

    1. 1r2 1l3
    2. 1l1 1r2
    3. 1l2 1h0

   One line is written for each cycle giving the cycle number, current
state, and an image of that portion of the tape that has been visited
so far.  The current position is indicated by reverse video (using
ANSI terminal escape sequences).

   Input errors are reported to standard error output and inhibit
execution.

   Bugs:

   Transitions to nonexistent states are not detected.
Reverse video should be parameterizable or at least optional.
There is no way to limit the number of cycles.
Infinite loops are not detected.  (Left as an exercise... :-)

Reference:

   Scientific American, August 1984, pp. 19-23.  A. K. Dewdney's
discussion of "busy beaver" turing machines in his "Computer
Recreations" column motivated this program.  The sample above
is the three-state busy beaver.

[ Full documentation | Source code ]


unclog.icn: Program to reformat CVS log output

Usage:  unclog [-n nnn] [file]

     -n nnn  maximum number of files to be listed individually
             (default is 50)

Unclog reads the output of "cvs log", as run without arguments in
a directory maintained by CVS, and reformats it to correlate CVS
changes that affected multiple files.  The log entries are produced
in chronological order.

[ Full documentation | Source code ]


unique.icn: Program to delete identical adjacent lines

Filters out identical adjacent lines in a file.

[ Full documentation | Source code ]


unpack.icn: Program to unpackage files

   This program unpackages files produced by pack.icn.  See that program
for information about limitations.

[ Full documentation | Source code ]


upper.icn: Program to map file names to uppercase

This program maps the names of all files in the current directory to
uppercase.

[ Full documentation | Source code ]


url2link.icn: Program to convert bookmarked URLs to link references

This program reads URLs from standard input and writes HTML links to
standard output.

[ Full documentation | Source code ]


utrim.icn: Program to remove unneeded procs from ucode

Usage:  utrim [-s | -v] file...

Utrim alters a set of uncode files comprising a complete Icon program
by removing unreferenced procedures.  The resulting files are smaller,
and they produce a smaller icode file.

The basename of each command argument is used to find a pair of
.u1 and .u2 files; each pair is renamed to .u1o and .u2o and
replaced by new .u1 and .u2 files.

-s invokes silent mode; -v invokes verbose mode.

Warning: utrim may break programs that use string invocation.

[ Full documentation | Source code ]


verse.icn: Program to generate bizarre verses

This verse maker was initially published in an early 1980s Byte magazine in
TRS80 Basic. In 1985 I translated it to BASICA, and in 1987 I translated it
to Icon. Recently, I've polished it to fetch the vocabulary all from one
file.

A vocabulary file can be specified on the command line; otherwise
file it looks for verse.dat by default. See that file for examples
of form.

[ Full documentation | Source code ]


versum.icn: Program to produce versum sequence

This program writes the versum sequence for an integer to a file of a
specified name.  If such a file exists, it picks up where
it left off, appending new values to the file.

The supported options are:

     -s i    The seed for the sequence, default 196
     -f s    Name of file to extend, no default
     -F s    Name of file, default <i>.vsq, where <i> is the
                seed of the sequence
     -t i    The number of steps to carry the sequence out to, default
                essentially unlimited
     -m i    Stop when value equals or exceeds m; default no limit

If both -f and -F are given, -f overrides.

[ Full documentation | Source code ]


vnq.icn: Program to display solutions to n-queens problem

This program displays solutions to the n-queens problem.

[ Full documentation | Source code ]


vrepl.icn: Program to replicate input lines

This program replicates every line of standard input a specified
number of times and writes the result to standard output.  The
replication factor is given on the command line.

[ Full documentation | Source code ]


weblinks.icn: Program to check links in HTML files

Weblinks is a program for checking links in a collection of HTML
files.  It is designed for use directly on the file structure
containing the HTML files.

Given one or more starting points, weblinks parses each file and
validates the HTTP: and FILE: links it finds.  Errors are reported
on standard output.  FILE: links, including relative links, can be
followed recursively.

[ Full documentation | Source code ]


what.icn: Program to identify source-code information

Writes all strings beginning with "@" followed by "(#)"
    and ending with null, newline, quotes, greater-than
    or backslash. Follows UNIX what conventions.

[ Full documentation | Source code ]


when.icn: Program to show file age

This one was developed for UNIX (namely ULTRIX 4.3 rev 44). Maybe
it will work on some other UNIX too. I'd like to know. This program
is called 'when'. It's like a date based ls command. Some have told
me 'find' can do the same things, but I find find a bit arcane?

So 'when' is what I use. Here are some samples:

     when before 4/12/92      # files before a date
     when before 300          # files older than an age
     when after 3/25          # or younger than a date this year
     when before 2/1/94 and after 10/31/93     # even a range

More options and clauses are supported. Look at the code for clues.
This one only works in the current directory. It also has an interesting
property. Maybe this is just ULTRIX, maybe not, I'd like to know anyway...
The interpreted version works fine, but the compiled version has a
numeric overflow. That'll make for some fun debugging. I wrote it for
myself as a tool to locate old files for archiving or deleting. Study and
enjoy!

[ Full documentation | Source code ]


wshfdemo.icn: Program to demonstrate weighted shuffle procedure

    This program is a short demo of the WeightedShuffle procedure.  The
user is first prompted for a random number seed.  Then, the user is asked
to enter a size for the list to be shuffled and what percentage of that
list to be shuffled.  The original and shuffled lists are then displayed.

[ Full documentation | Source code ]


xtable.icn: Program to show character code translations

Program to print various character translation tables.  See
procedure help() for the capabilities.

[ Full documentation | Source code ]


yahtz.icn: Program to play yahtzee

Modified by Richard Goerwitz with corrections by Phillip Lee Thomas

[ Full documentation | Source code ]


yescr.icn: Program to convert UNIX files to DOS format

  This program simply inserts MS-DOS carriage-return+linefeed
sequences in place of UNIX newlines.  Effects conversion from the
native UNIX text file format to its DOS correspondent.

     usage:  yescr file1 [file2 [etc.]]

Bug:  Doesn't check to see whether the input files are in fact
text files.

[ Full documentation | Source code ]


zipsort.icn: Program to sort mailing labels by ZIP code

   This program sorts labels produced by labels in ascending
order of their postal zip codes.

Option:

   The option -d n sets the number of lines per label to n.
The default is 9. This value must agree with the value used to
format the labels.

Zip Codes:

   The zip code must be the last nonblank string at the
end of the label.  It must consist of digits but may have an
embedded dash for extended zip codes.  If a label does not end
with a legal zip code, it is placed after all labels with legal
zip codes.  In such a case, an error messages also is written to
standard error output.

[ Full documentation | Source code ]


Program Library Page | Icon Home Page