Full Documentation: Basic Programs

Icon version 9.5.20f

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

November 19, 1997; Ralph E. Griswold
See also: address.doc, adlcount.icn, adlfiltr.icn, adllist.icn, adlsort,icn, labels.icn Links: adlutils, options
This file is in the public domain.
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

[ Summary entry | Source code ]


adlcount.icn: Program to count address list entries

November 19, 1997; Ralph E. Griswold
See also: address.doc, adlcheck.icn, adlfiltr.icn, adllist.icn, adlsort,icn, labels.icn
This file is in the public domain.
   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.

[ Summary entry | Source code ]


adlfiltr.icn: Program to filter address list entries

September 2, 1991; Ralph E. Griswold
See also: address.doc, adlcheck.icn, adlcount.icn, adllist.icn, adlsort,icn, labels.icn Links: adlutils, options
This file is in the public domain.
  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

[ Summary entry | Source code ]


adlfirst.icn: Program to write first line of addresses

November 19, 1997; Ralph E. Griswold
See also: address.doc, adlcheck.icn, adlfiltr.icn, adllist.icn, adlsort,icn, labels.icn
This file is in the public domain.
   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.

[ Summary entry | Source code ]


adllist.icn: Program to list address list fields

November 19, 1997; Ralph E. Griswold
See also: address.doc, adlcheck.icn, adlcount.icn, adlfiltr.icn, adlsort,icn, labels.icn Links: adlutils, options
This file is in the public domain.
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.

[ Summary entry | Source code ]


adlsort.icn: Program to sort address list entries

November 19, 1997; Ralph E. Griswold
See also: address.doc, adlcount.icn, adlfiltr.icn, adllist.icn, adlsort,icn, labels.icn Links: adlutils, options, namepfx
This file is in the public domain.
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.

[ Summary entry | Source code ]


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

March 2, 1996; Robert J. Alexander
This file is in the public domain.
   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).

[ Summary entry | Source code ]


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

November 25, 1996; Ralph E. Griswold
This file is in the public domain.
This program applies a function specified on the command line to the
lines of a file.

[ Summary entry | Source code ]


banner.icn: Program to display banner

September 21, 1993; Chris Tenaglia
This file is in the public domain.
   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!

[ Summary entry | Source code ]


based.icn: Program to do BASIC-style editing

February 18, 1996; Chris Tenaglia
This file is in the public domain.
This program models a line editor for BASIC.

[ Summary entry | Source code ]


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

December 4, 1996; Gregg M. Townsend
This file is in the public domain.
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

[ Summary entry | Source code ]


bj.icn: Program to play blackjack game

December 12, 1995; Chris Tenaglia (modified by Richard L. Goerwitz)
This file is in the public domain.
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.

[ Summary entry | Source code ]


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

August 13, 1995; Ralph E. Griswold
This file is in the public domain.
This program converts strings of two or more blanks to tabs.  It
reads from standard input and writes to standard output.

[ Summary entry | Source code ]


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

March 11, 1993; Robert J. Alexander
This file is in the public domain.
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 .

[ Summary entry | Source code ]


calc.icn: Program to simulate desk calculator

January 3, 1993; Ralph E. Griswold
This file is in the public domain.
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.

[ Summary entry | Source code ]


catlines.icn: Program to concatenate lines of a file

January 14, 1999; Ralph E. Griswold
This file is in the public domain.
This program concatenates all the lines from standard input and
writes the result to standard output.

[ Summary entry | Source code ]


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

March 26, 2002; Ralph E. Griswold
This file is in the public domain.
This program lists all the different characters in a file.  image()
is used to show printable representations.

[ Summary entry | Source code ]


chkhtml.icn: Program to check HTML files

November 15, 1994; Robert J. Alexander
This file is in the public domain.
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.

[ Summary entry | Source code ]


choose.icn: Program to pick lines from a file

January 14, 2002; Gregg M. Townsend
This file is in the public domain.
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.

[ Summary entry | Source code ]


chop.icn: Program to restrict numerical values

January 21, 1999; Ralph E. Griswold
This file is in the public domain.
This program limits the numerical values in a sequence
visualization stream.  The limit is given on the command line;
default 200.

[ Summary entry | Source code ]


colm.icn: Program to arrange data into columns

December 5, 1989; Robert J. Alexander
This file is in the public domain.
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.

[ Summary entry | Source code ]


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

March 21, 1994; Ralph E. Griswold
Requires: UNIX
This file is in the public domain.
This program lists common file names in two directories given as
command-line arguments.

[ Summary entry | Source code ]


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

January 7, 1997; Ralph E. Griswold
Requires: UNIX
This file is in the public domain.
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.

[ Summary entry | Source code ]


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

October 4, 1997; Ralph E. Griswold
This file is in the public domain.
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.

[ Summary entry | Source code ]


concord.icn: Program to produce concordance

October 9, 1994; Ralph E. Griswold
This file is in the public domain.
   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.
____________________________________________________________

   Note that the program is organized to make it easy (via item()) to
handle other kinds of tabulations.

[ Summary entry | Source code ]


conman.icn: Program to convert units

May 2, 2001; William E. Drissel
Requires: conman.sav
This file is in the public domain.
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).
____________________________________________________________

Program Notes:

The procedure, process, parses the user's string to see if it
begins with a keyword.  If so, it acts accordingly.  If not,
the user string is fed to isare.

Isare attempts to find "is" or "are" in the users string.
Failing to, isare feeds the string to conman which can
interpret anything.  If "is" or "are" is found, the tokens
(delimited by blanks) before the "is" or "are" are stacked in
foregoing; those after are stacked in subsequent.  Then the
name to be defined is popped off the foregoing and used as
the "index" into a table named values.  The corresponding
number is computed as eval(subsequent) / eval(foregoing).

The procedure, stack, is based on Griswold and Griswold, "The
Icon Programming Language", p122.

The procedure, eval, unstacks the tokens from a stack one by
one until all have been considered.  First, the tokens which
signify division by the next token are considered and used to
set a switch named action.  Then depending on action, the
token is used to multiply the accumulator or divide it.  If
eval can make the token into a number, the number is used,
failing that the token is looked up in the table named values
and the corresponding number is used.  Failing both of those,
conman gripes to the user and does nothing (in effect
multiplying or dividing by 1).  Finally, eval returns the
number accumulated by the operations with the tokens.

Load defaults the filename to conman.sav if the user didn't
supply one.  Each line read is fed to isare.  We will see
that save prepares the lines so isare can define the units.

Save uses Icon's sort to go thru the table "values".  The
unit name is the left of a pair and the number stored is the
right of the pair.  The word " is " is stuck between them so
isare will work.

Finally, we consider the procedure conman.  During initial
design, this was perceived to be the largest part of the
effort of conman.  It is a real tribute to the power of Icon
that only one non-trivial line of code is required.  The
user's string is reproduced then the word "equals" followed
the result produced by eval after the user's string is
stacked.

[ Summary entry | Source code ]


countlst.icn: Program to count items in a list

December 30, 1991; Ralph E. Griswold
This file is in the public domain.
   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.

[ Summary entry | Source code ]


cross.icn: Program to display intersection of words

June 10, 1988; William P. Malloy
This file is in the public domain.
   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.

[ Summary entry | Source code ]


crypt.icn: Program to encrypt file

August 14, 1996; Phil Bewig and Phillip Lee Thomas
This file is in the public domain.
Do *not* use this in the face of competent cryptanalysis.

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

As written, uses UNIX-style console I/O.

[ Summary entry | Source code ]


csgen.icn: Program to generate context-sensitive sentences

November 19, 1997; Ralph E. Griswold
This file is in the public domain.
   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.

[ Summary entry | Source code ]


cstrings.icn: Program to print strings in C files

September 17, 1990; Robert J. Alexander
This file is in the public domain.
Program to print all strings (enclosed in double quotes) in C source
files.

[ Summary entry | Source code ]


cwd.icn: Program to write current working directory

June 10, 1994; Ralph E. Griswold
Requires: UNIX
This file is in the public domain.
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`

[ Summary entry | Source code ]


datmerge.icn: Program to merge data files

November 16, 2001; Gregg M. Townsend
This file is in the public domain.
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.

[ Summary entry | Source code ]


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

June 29, 1994; Nevin Liber
This file is in the public domain.
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.
____________________________________________________________

NumberOfDays(sMonth, iDay, iYear) : iNumberOfDays

NumberOfDays() returns the number of days into iYear that sMonth/iDay
occurs.  For instance, NumberOfDays("February", 28) returns 59, since
it is the 59th day into any year.  Leap years from 1901 until 2099
are taken into account.  It fails if any parameters are bad.

Defaults:
    sMonth  current month
    iDay    current day of the current month
    iYear   current year

[ Summary entry | Source code ]


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

August 2, 2001; Gregg M. Townsend
This file is in the public domain.
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.

[ Summary entry | Source code ]


deal.icn: Program to deal bridge hands

August 14, 1996; Ralph E. Griswold
This file is in the public domain.
   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.

[ Summary entry | Source code ]


declchck.icn: Program to detect possible declaration errors

August 14, 1996; Ralph E. Griswold
Requires: UNIX
This file is in the public domain.
This program examines ucode files and reports declared identifiers
that may conflict with function names.

[ Summary entry | Source code ]


delam.icn: Program to delaminate file

June 10, 1988; Thomas R. Hicks
This file is in the public domain.
   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.

[ Summary entry | Source code ]


delamc.icn: Program to delaminate file using tab characters

May 28, 1989; Thomas R. Hicks
This file is in the public domain.
   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.

[ Summary entry | Source code ]


dellines.icn: Program to delete lines from a file

December 28, 1996; Ralph E. Griswold
This file is in the public domain.
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.

[ Summary entry | Source code ]


delta.icn: Program to list differences between successive numbers

January 22, 1999; Ralph E. Griswold
This file is in the public domain.
This program reads a stream of numbers from standard input and write
a stream of their first differences to standard output.

[ Summary entry | Source code ]


diffn.icn: Program to show differences among files

January 3, 1994; Robert J. Alexander
This file is in the public domain.
This program shows the differences between n files. Is is invoked as

     diffn file1 file2 ... filen
____________________________________________________________

Most of the work is done by an external procedure, dif().  This
program analyzes the command line arguments, sets up a call to
dif(), and displays the results.

[ Summary entry | Source code ]


diffsort.icn: Program to reorder "diff" output

May 31, 1994; Gregg M. Townsend
This file is in the public domain.
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.

[ Summary entry | Source code ]


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

August 14, 2007; Gregg M. Townsend
This file is in the public domain.
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.

[ Summary entry | Source code ]


diffu.icn: Program to show differences in files

January 3, 1993; Rich Morin
This file is in the public domain.
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

[ Summary entry | Source code ]


diffword.icn: Program to list different words

May 9, 1989; Ralph E. Griswold
This file is in the public domain.
This program lists all the different words in the input text.
The definition of a "word" is naive.

[ Summary entry | Source code ]


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

November 25, 1996; Ralph E. Griswold
This file is in the public domain.
This program filters input to produce the nth column of digit date.

[ Summary entry | Source code ]


diskpack.icn: Program to produce packing list for diskettes

June 10, 1994; Ralph E. Griswold
Requires: UNIX
This file is in the public domain.
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"

[ Summary entry | Source code ]


duplfile.icn: Program to find directories with same files

June 10, 1994; Ralph E. Griswold
Requires: UNIX
This file is in the public domain.
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.

[ Summary entry | Source code ]


duplproc.icn: Program to find duplicate declarations

December 30, 1991; Richard L. Goerwitz
Requires: UNIX (MS-DOS will work if all files are in MS-DOS format)
This file is in the public domain.
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.

[ Summary entry | Source code ]


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

March 7, 1998; Ralph E. Griswold
This file is in the public domain.
   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.

[ Summary entry | Source code ]


empg.icn: Program to make expression-evaluation programs

December 16, 1998; Ralph E. Griswold
This file is in the public domain.
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.
____________________________________________________________

The following options are supported:

     -l i    use i for the number of loop iterations, default 100000
     -d i    use i for the "delta" to adjust timings; otherwise it
               is computed when the expression-evaluation program
               is run

[ Summary entry | Source code ]


envelope.icn: Program to address envelopes

August 14, 1996; Ronald Florence
This file is in the public domain.
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>.

[ Summary entry | Source code ]


evaluate.icn: Program to evaluate Icon expressions

March 4, 1995; Ralph E. Griswold
This file is in the public domain.
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

[ Summary entry | Source code ]


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

September 17, 1998; Ralph E. Griswold
This file is in the public domain.
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.

[ Summary entry | Source code ]


farb.icn: Program to generate Farberisms

June 14, 1994; Ralph E. Griswold
This file is in the public domain.
   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.''

[ Summary entry | Source code ]


farb2.icn: Program to generate Farberisms

June 14, 1994; Alan Beale
This file is in the public domain.
   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.''
____________________________________________________________

   This program obtains its farberisms from the farber.sen file to
allow additional farberisms to be added without recompilation or
straining the limits of the Icon translator.  It builds an index file
farber.idx to allow for efficient access to the sentences file.  The
use of untranslated I/O for the index file is necessary for correct
behavior on some systems (e.g., MVS).

[ Summary entry | Source code ]


filecnvt.icn: Program to convert line terminators

August 14, 1996; Beth Weiss
This file is in the public domain.
   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

[ Summary entry | Source code ]


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

September 17, 1998; Ralph E. Griswold
This file is in the public domain.
The files to be includes are listed on the command line.  There is no
check that the files actually exist.

[ Summary entry | Source code ]


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

November 25, 1996; Ralph E. Griswold
This file is in the public domain.
This program creates files used in the construction of indexes for the
Icon program library.

[ Summary entry | Source code ]


fileprnt.icn: Program to display characters in file

November 21, 1989; Ralph E. Griswold
Requires: co-expressions
This file is in the public domain.
   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.
____________________________________________________________

Program note:

   This program illustrates a situation in which co-expressions can be
used to considerably simplify programming.  Try recasting it without
co-expressions.

[ Summary entry | Source code ]


filerepl.icn: Program to replicate file

January 2, 1999; Ralph E. Griswold
This file is in the public domain.
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.

[ Summary entry | Source code ]


filesect.icn: Program to produce section of a file

March 26, 2002; Ralph E. Griswold
This file is in the public domain.
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.

[ Summary entry | Source code ]


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

July 7, 1994; David Gamey
Requires: MS-DOS compatible operating system
This file is in the public domain.
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

[ Summary entry | Source code ]


filtskel.icn: Program skeleton for generic filter

July 16, 1994; Robert J. Alexander
This file is in the public domain.
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.

[ Summary entry | Source code ]


findstr.icn: Program to find embedded character strings

March 26, 2002; Robert J. Alexander
This file is in the public domain.
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.

[ Summary entry | Source code ]


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

November 21, 1996; Phillip Lee Thomas
This file is in the public domain.
 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.

[ Summary entry | Source code ]


fixhqx.icn: Program to strip headers from BinHex files

February 20, 1994; Ralph E. Griswold
This file is in the public domain.
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.

[ Summary entry | Source code ]


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

November 14, 1994; Gregg M. Townsend
This file is in the public domain.
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.

[ Summary entry | Source code ]


fnctab.icn: Program to list function usage

June 18, 1994; Ralph E. Griswold
This file is in the public domain.
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.

[ Summary entry | Source code ]


fnctmpl.icn: Program to produce function templates

February 27, 1992; Ralph E. Griswold
This file is in the public domain.
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.

[ Summary entry | Source code ]


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

March 26, 2002; Robert J. Alexander
This file is in the public domain.
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.

[ Summary entry | Source code ]


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

June 10, 1995; Ralph E. Griswold
This file is in the public domain.
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).

[ Summary entry | Source code ]


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

October 26, 1999; Ralph E. Griswold
This file is in the public domain.
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).
____________________________________________________________

This program was translated from a C program by Gregg Townsend.  His
documentation includes the following remarks.

 rational mode based on a calculator algorithm posted by:

     Joseph D. Rudmin  (duke!dukempd!jdr)
     Duke University Physics Dept.
     Aug 19, 1987

 n.b. for an interesting sequence try "fract .6180339887498948482".
 Do you know why?  (Hint: "Leonardo of Pisa").

[ Summary entry | Source code ]


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

June 10, 1988; Thomas R. Hicks
Requires: UNIX
See also: gcomp.icn
This file is in the public domain.
 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.

[ Summary entry | Source code ]


fuzz.icn: Program to perform fuzzy pattern matching

November 10, 1993; Alex Cecil
This file is in the public domain.
   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.

[ Summary entry | Source code ]


gcomp.icn: Program to produce complement of file specification

December 27, 1989; William H. Mitchell, modified by Ralph E. Griswold
Requires: UNIX
This file is in the public domain.
   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.

[ Summary entry | Source code ]


geddump.icn: Program to dump contents of GEDCOM file

July 3, 1998; Gregg M. Townsend
This file is in the public domain.
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.

[ Summary entry | Source code ]


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

July 9, 1993; Robert J. Alexander
Requires: pipes, a "diff" command in the environment
See also: diffn.icn (a diff-type program)
This file is in the public domain.
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.

[ Summary entry | Source code ]


gener.icn: Program to generate sequence from Icon expression

January 21, 1999; Ralph E. Griswold
Requires: system(), pipes
This file is in the public domain.
This program takes an Icon expression is given on the command line, and
writes its results to standard output.  Watch for syntactic problems.

[ Summary entry | Source code ]


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

January 22, 1999; Ralph E. Griswold
Requires: system(), pipes
This file is in the public domain.
This program writes the results of an Icon expression given in the file
named on the command line.

[ Summary entry | Source code ]


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

October 25, 1990; Peter A. Bigot
This file is in the public domain.
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.

[ Summary entry | Source code ]


getcol.icn: Program to extract column from data

March 26, 2002; Ralph E. Griswold
This file is in the public domain.
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'

[ Summary entry | Source code ]


getlines.icn: Program to extract lines from a file

March 26, 2002; Ralph E. Griswold
This file is in the public domain.
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.

[ Summary entry | Source code ]


gftrace.icn: Program for generating function tracing procedures

August 8, 1997; Gregg M. Townsend
This file is in the public domain.
   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.

[ Summary entry | Source code ]


graphdem.icn: Program to demonstrate simple bar graphics

November 19, 1997; Matthias Heesch
Requires: ANSI terminal support
This file is in the public domain.
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

[ Summary entry | Source code ]


grpsort.icn: Program to sort groups of lines

June 10, 1988; Thomas R. Hicks
This file is in the public domain.
   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

[ Summary entry | Source code ]


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

January 3, 1994; Alan D. Corre (ported to UNIX by Richard L. Goerwitz)
Requires: UNIX, hebcalen.dat, hebcalen.hlp
See also: hebcalen.icn
This file is in the public domain.
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.
____________________________________________________________

Revised October 25, 1993 by Ralph E. Griswold to use dopen().

[ Summary entry | Source code ]


headicon.icn: Program to add header to Icon program

November 20, 1997; Ralph E. Griswold
Requires: system(), vi(1)
This file is in the public domain.
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().

[ Summary entry | Source code ]


hebcalen.icn: Program for combination Jewish/Civil calendar

January 3, 1993; Alan D. Corre
Requires: keyboard functions, hebcalen.dat, hebcalen.hlp
See also: hcal4unx.icn
This file is in the public domain.
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.
____________________________________________________________

Revised October 25, 1993 by Ralph E. Griswold to use dopen() to
find data files.

[ Summary entry | Source code ]


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

May 2, 2001; Alan D. Corre
Requires: ProIcon
This file is in the public domain.
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.

[ Summary entry | Source code ]


hotedit.icn: Program to edit a Mosaic hotlist

June 23, 2000; Gregg M. Townsend
Requires: Unix, NCSA Mosaic
This file is in the public domain.
===> 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.

[ Summary entry | Source code ]


hr.icn: Program to play horse-race game

August 14, 1996; Chris Tenaglia
This file is in the public domain.
This program implements a horse-race game.

[ Summary entry | Source code ]


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

May 15, 2002; Gregg M. Townsend
Requires: UNIX, dynamic loading
This file is in the public domain.
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.

[ Summary entry | Source code ]


htprep.icn: Program to prepare HTML files

November 3, 2000; Gregg M. Townsend
This file is in the public domain.
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.

[ Summary entry | Source code ]


huffstuf.icn: Program for huffman coding

April 30, 1993; Richard L. Goerwitz
See also: hufftab.icn, press.icn
This file is in the public domain.
An odd assortment of tools that lets me compress text using an
Iconish version of a generic Huffman algorithm.

[ Summary entry | Source code ]


hufftab.icn: Program to compute Huffman state transitions

November 14, 1994; Gregg M. Townsend
This file is in the public domain.
   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

[ Summary entry | Source code ]


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

June 8, 1994; Ralph E. Griswold
This file is in the public domain.
This program replaces comment bars in Icon programs by bars 76 characters
long -- the program library standard.

[ Summary entry | Source code ]


ibrow.icn: Program to browse Icon files for declarations

September 7, 1990; Robert J. Alexander
Requires: UNIX
This file is in the public domain.
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.

[ Summary entry | Source code ]


icalc.icn: Program to simulate infix desk calculator

January 3, 1994; Stephen B. Wampler
This file is in the public domain.
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)

[ Summary entry | Source code ]


icalls.icn: Program to tabulate Icon calls

November 25, 1992; Ralph E. Griswold
This file is in the public domain.
This program processes trace output and tabulates calls of procedures

[ Summary entry | Source code ]


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

March 11, 1993; Robert J. Alexander
This file is in the public domain.
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 "}"

[ Summary entry | Source code ]


icontent.icn: Program to list Icon procedures

August 17, 1990; Robert J. Alexander
This file is in the public domain.
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)

[ Summary entry | Source code ]


icvt.icn: Program for ASCII/EBCDIC program conversion

May 2, 2001; Cheyenne Wills, modified by Ralph E. Griswold
This file is in the public domain.
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.

[ Summary entry | Source code ]


idepth.icn: Program to report maximum recursion depth

May 2, 2001; Ralph E. Griswold
This file is in the public domain.
This program processes trace output and reports the maximum depth of
recursion.

[ Summary entry | Source code ]


idxtext.icn: Program for creating indexed text-base

July 9, 1991; Richard L. Goerwitz
This file is in the public domain.
    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)

[ Summary entry | Source code ]


ifilter.icn: Program to filter lines of file

January 21, 1999; Ralph E. Griswold
This file is in the public domain.
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
____________________________________________________________

Note:  This is a renaming of an earlier program, filter.icn, to
avoid name collisions on systems where there already is a utility
named filter.

[ Summary entry | Source code ]


ifncsgen.icn: Program to generate procedure wrappers for functions

September 28, 1996; Ralph E. Griswold
This file is in the public domain.
This program generates a procedure for every (built-in) function
that calls the function.

[ Summary entry | Source code ]


igrep.icn: Program for string search similar to egrep

May 1, 1994; Robert J. Alexander
This file is in the public domain.
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.

[ Summary entry | Source code ]


iheader.icn: Program to list Icon program library headers

June 14, 1994; Ralph E. Griswold
This file is in the public domain.
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.

[ Summary entry | Source code ]


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

December 5, 1989; Robert J. Alexander
This file is in the public domain.
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.

[ Summary entry | Source code ]


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

May 2, 2001; Richard L. Goerwitz, enhanced by Frank J. Lhota
See also: iiencode.icn
This file is in the public domain.
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.

[ Summary entry | Source code ]


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

May 2, 2001; Richard L. Goerwitz, enhanced by Frank J. Lhota
See also: iidecode.icn
This file is in the public domain.
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.

[ Summary entry | Source code ]


ilnkxref.icn: Program to produce Icon link cross reference

August 3, 2000; Robert J. Alexander
Requires: UNIX
This file is in the public domain.
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

[ Summary entry | Source code ]


ilump.icn: Program to lump linked Icon source files

November 14, 1994; Gregg M. Townsend
This file is in the public domain.
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.

[ Summary entry | Source code ]


imagetyp.icn: Program to show types of image files

May 2, 2001; Ralph E. Griswold
This file is in the public domain.
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.

[ Summary entry | Source code ]


indxcomp.icn: Program to assist in index compilation

June 23, 2000; Ralph E. Griswold
This file is in the public domain.
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.

[ Summary entry | Source code ]


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

May 18, 1994; Robert J. Alexander
This file is in the public domain.
Program to determine Icon modules required by an Icon module.  Expects
environment variable LPATH to be set properly as for the Icon Compiler.

[ Summary entry | Source code ]


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

August 13, 1995; Ralph E. Griswold
This file is in the public domain.
This program lists lines common to two files.

[ Summary entry | Source code ]


interpe.icn: Program to interpret Icon expressions

December 30, 1991; Ralph E. Griswold
Requires: UNIX See also: interpp.icn
This file is in the public domain.
  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.

[ Summary entry | Source code ]


interpp.icn: Program to interpret Icon programs

December 30, 1991; Jerry Nowlin
See also: interpe.icn
This file is in the public domain.
  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.

[ Summary entry | Source code ]


ipatch.icn: Program to patch iconx path in executable

November 15, 2000; Gregg M. Townsend
Requires: Unix
This file is in the public domain.
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.

[ Summary entry | Source code ]


ipldoc.icn: Program to collect library documentation

November 26, 1996; Ralph E. Griswold
This file is in the public domain.
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

[ Summary entry | Source code ]


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

March 3, 1996; Ralph E. Griswold
This file is in the public domain.
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.

[ Summary entry | Source code ]


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

May 2, 2001; Stephen B. Wampler, modified by Ralph E. Griswold
This file is in the public domain.
   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".

[ Summary entry | Source code ]


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

May 2, 2001; Justin Kolb
This file is in the public domain.
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.

[ Summary entry | Source code ]


ipower.icn: Program to write sequence of powers

December 29, 1996; Ralph E. Griswold
This file is in the public domain.
This program generates integers in sequence.

The following options are supported:

     -v i    value to be raise to power; default 2
     -b i    beginning power; default 1
     -e i    ending power; default no end
     -i i    increment; default 1
     -l i    limit on number of powers generated; default no limit

Large integer values are not supported.

[ Summary entry | Source code ]


ipp.icn: Program to preprocess Icon programs

March 26, 2002; Robert C. Wieland, revised by Frank J. Lhota
This file is in the public domain.
   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.
____________________________________________________________

Ipp may be invoked from the command line as:

  ipp [option  ...] [ifile [ofile]]

   Two file names may be specified as arguments.  'ifile' and 'ofile' are
respectively the input and output files for the preprocessor.  By default
these are standard input and standard output.  If the output file is to be
specified while the input file should remain standard input a dash ('-')
should be given as 'ifile'.  For example, 'ipp - test' makes test the output
file while retaining standard input as the input file.

   The following special names are predefined by ipp and may not be
redefined #  or undefined.  The name _LINE_ is defined as the line number
(as an integer) of the line of the source file currently processed.  The
name _FILE_ is defined as the name of the current source file
(as a string).  If the source is standard input then it has the value
'stdin'.

   Ipp will also set _LINE_ and _FILE_ from the "#line" directives it
encounters, and will insert line directives to indicate source origins.

   Also predefined are names corresponding to the features supported by the
implementation of Icon at the location the preprocessor is run.  This allows
conditional translations using the 'if' commands, depending on what features
are available.  Given below is a list of the features on a 4.nbsd UNIX
implementation and the corresponding predefined names:

     Feature                         Name
     -----------------------------------------------------
     UNIX                            UNIX
     co-expressions                  co_expressions
     overflow checking               overflow_checking
     direct execution                direct_execution
     environment variables           environment_variables
     error traceback                 error_traceback
     executable images               executable_images
     string invocation               string_invocation
     expandable regions              expandable_regions


Command-Line Options:
---------------------

  The following options to ipp are recognized:

 -C          By default ipp strips Icon-style comments.  If this option
             is specified all comments are passed along except those
             found on ipp command lines (lines starting with  a '$'
             command).

 -D name
 -D name=def Allows the user to define a name on the command line instead
             of using a $define command in a source file.  In the first
             form the name is defined as '1'.  In the second form name is
             defined as the text following the equal sign.  This is less
             powerful than the $define command line since def can not
             contain any white space (spaces or tabs).

 -d depth    By default ipp allows include files to be nested to a depth
             of ten.  This allows the preprocessor to detect infinitely
             recursive include sequences.  If a different limit for the
             nesting depth is needed it may changed by using this option
             with an integer argument greater than zero. Also, if a file
             is found to already be in a nested include sequence an
             error message is written regardless of the limit.

 -I dir      The following algorithm is normally used in searching for
             $include files.  On a UNIX system names enclosed in "" are
             searched for by trying in order the directories specified by the
             PATH environment variable, and names enclosed in <> are always
             expected to be in the /usr/icon/src directory.  On other systems
             names enclosed in <> are searched for by trying in order the
             directories specified by the IPATH environment variable; names
             in "" are searched for in a similar fashion, except that the
             current directory is tried first.  If the -I option is given the
             directory specified is searched before the 'standard'
             directories.  If this option is specified more than once the
             directories specified are tried in the order that they appear on
             the command line, then followed by the 'standard' directories.

Preprocessor commands:
----------------------

   All ipp commands start with a line that has '$' as its first non-space
character.  The name of the command must follow the '$'.  White space
(any number of spaces or tabs) may be used to separate the '$' and the
command name.  Any line beginning with a '$' and not followed by a valid
name will cause an error message to be sent to standard error and
termination of the preprocessor.  If the command requires an argument then
it must be separated from the command name by white space otherwise the
argument will be considered part of the name and the result will likely
produce an error.  In processing the $ commands ipp responds to exceptional
conditions in one of two ways.  It may produce a warning and continue
processing or produce an error message and terminate.  In both cases the
message is sent to standard error.  With the exception of error conditions
encountered during the processing of the command line, the messages normally
include the name and line number of the source file at the point the
condition was encountered.  Ipp was designed so that most exception
conditions encountered will produce errors and terminate.  This protects the
user since warnings could simply be overlooked or misinterpreted.

   Many ipp command require names as arguments.  Names must begin with a
letter or an underscore, which may be followed by any number of letters,
underscores, and digits.  Icon-style comments may appear on ipp command
lines, however they must be separated from the normal end of the command by
white_space.  If any extraneous characters appear on a command line a
warning is issued.  This occurs when characters other than white-space or a
comment follow the normal end of a command.

   The following commands are implemented:

  $define:  This command may be used in one of two forms.  The first form
         only allows simple textual substitution.  It would be invoked as
         '$define name text'.  Subsequent occurrences of name are replaced
         with text.  Name and text must be separated by one white space
         character which is not considered to be part of the replacement
         text.  Normally the replacement text ends at the end of the line.
         The text however may be continued on the next line if the backslash
         character '\' is the last character on the line.  If name occurs
         in the replacement text an error message (recursive textual substi-
         tution) is written.

         The second form is '$define name(arg,...,arg) text' which defines
         a macro with arguments.  There may be no white space between the
         name and the '('.  Each occurrence of arg in the replacement text
         is replaced by the formal arg specified when the macro is
         encountered.   When a macro with arguments is expanded the arguments
         are placed into the expanded replacement text unchanged.  After the
         entire replacement text is expanded, ipp restarts its scan for names
         to expand at the beginning of the newly formed replacement text.
         As with the first form above, the replacement text may be continued
         on following lines.  The replacement text starts immediately after
         the ')'.
         The names of arguments must comply with the convention for regular
         names.  See the section below on Macro processing for more
         information on the replacement process.

  $undef:   Invoked as '$undef name'.   Removes the definition of name.  If
         name is not a valid name or if name is one of the reserved names
         _FILE_ or _LINE_ a message is issued.

  $include: Invoked as '$include <filename>' or '$include "filename"'.  This
         causes the preprocessor to make filename the new source until
         end of file is reached upon which input is again taken from the
         original source.  See the -I option above for more detail.

  $dump:    This command, which has no arguments, causes the preprocessor to
         write to standard error all names which are currently defined.
         See '$ifdef' below for a definition of 'defined'.

  $warning:
            This command issues a warning, with the text coming from the
         argument field of the command.

  $error:   This command issues a error, with the text coming from the
         argument field of the command.  As with all errors, processing
         is terminated.

  $ifdef:   Invoked as 'ifdef name'.  The lines following this command appear
         in the output only if the name given is defined.  'Defined' means
           1.  The name is a predefined name and was not undefined using
               $undef, or
           2.  The name was defined using $define and has not been undefined
               by an intervening $undef.

  $ifndef:  Invoked as 'ifndef name'.  The lines following this command do
         not appear in the output if the name is not defined.

  $if:      Invoked as 'if constant-expression'.  Lines following this
         command are processed only if the constant-expression produces a
         result. The following arithmetic operators may be applied to
         integer arguments: + - * / % ^

         If an argument to one of the above operators is not an integer an
         error is produced.

            The following functions are provided: def(name), ndef(name)
         This allows the utility of $ifdef and $ifndef in a $if command.
         def produces a result if name is defined and ndef produces a
         result if name is not defined.

            The following comparison operators may be used on integer
         operands:

         > >= = < <= ~=

            Also provided are alternation (|), conjunction (&), and
         negation (not).  The following table lists all operators with
         regard to decreasing precedence:

             not + - (unary)
             ^ (associates right to left)
             * / %
             + - (binary)
             > >= = < <= ~=
             |
             &

         The precedence of '|' and '&' are the same as the corresponding
         Icon counterparts.  Parentheses may be used for grouping.
         Backtracking is performed, so that the expression

             FOO = (1|2)

         will produce a result precisely when FOO is either 1 or 2.

  $elif:    Invoked as 'elif constant-expression'.  If the lines preceding
         this command were processed, this command and the lines following
         it up to the matching $endif command are ignored.  Otherwise,
         the constant-expression is evaluated, and the lines following this
         command are processed only if it produces a result.

  $else:    This command has no arguments and reverses the notion of the
         test command which matches this directive.  If the lines preceding
         this command where ignored the lines following are processed, and
         vice versa.

  $endif:   This command has no arguments and ends the section of lines
         begun by a test command ($ifdef, $ifndef, or $if).  Each test
         command must have a matching $endif.

Macro Processing and Textual Substitution
-----------------------------------------
   No substitution is performed on text inside single quotes (cset literals)
and double quotes (strings) when a line is processed.   The preprocessor
will #  detect unclosed cset literals or strings on a line and issue an
error message unless the underscore character is the last character on the
line.  The output from

     $define foo bar
     write("foo")

is

     write("foo")

   Unless the -C option is specified comments are stripped from the source.
Even if the option is given the text after the '#' is never expanded.

   Macro formal parameters are recognized in $define bodies even inside cset
constants and strings.  The output from

     $define test(a)         "a"
     test(processed)

is the following sequence of characters: "processed".

   Macros are not expanded while processing a $define or $undef.  Thus:

     $define off invalid
     $define bar off
     $undef off
     bar

produces off.  The name argument to $ifdef or $ifndef is also not expanded.

   Mismatches between the number of formal and actual parameters in a macro
call are caught by ipp.  If the number of actual parameters is greater than
the number of formal parameters is error is produced.  If the number of
actual parameters is less than the number of formal parameters a warning is
issued and the missing actual parameters are turned into null strings.
____________________________________________________________

  The records and global variables used by ipp are described below:

Src_desc:            Record which holds the 'file descriptor' and name
                     of the corresponding file.  Used in a stack to keep
                     track of the source files when $includes are used.
Opt_rec              Record returned by the get_args() routine which returns
                     the options and arguments on the command line.  options
                     is a cset containing options that have no arguments.
                     pairs is a list of [option,  argument] pairs. ifile and
                     ofile are set if the input or output files have been
                     specified.
Defs_rec             Record stored in a table keyed by names.  Holds the
                     names of formal arguments, if any, and the replacement
                     text for that name.
Expr_node            Node of a parse tree for $if / $elif expressions.
                     Holds the operator, or a string representing the
                     control structure.  Also, holds a list of the args for
                     the operation / control structure, which are either
                     scalars or other Expr_node records.
Chars                Cset of all characters that may appear in the input.
Defs                 The table holding the definition data for each name.
Depth                The maximum depth of the input source stack.
Ifile                Descriptor for the input file.
Ifile_name           Name of the input file.
Init_name_char       Cset of valid initial characters for names.
Line_no              The current line number.
Name_char            Cset of valid characters for names.
Non_name_char        The complement of the above cset.
Ofile                The descriptor of the output file.
Options              Cset of no-argument options specified on the command
                     line.
Path_list            List of directories to search in for "" include files.
Src_stack            The stack of input source records.
Std_include_paths    List of directories to search in for <> include files.
White_space          Cset for white-space characters.
TRUE                 Defined as 1.

[ Summary entry | Source code ]


iprint.icn: Program to print Icon program

March 26, 2002; Robert J. Alexander
This file is in the public domain.
   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.

[ Summary entry | Source code ]


iprofile.icn: Program to profile Icon procedure usage

May 2, 2001; Richard L. Goerwitz
Requires: co-expressions, keyboard functions, pipes, UNIX
This file is in the public domain.
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.

[ Summary entry | Source code ]


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

procedure parse:           parse a profile line, failing on err
procedure nofile:          summarize a file not found
procedure listfile:        list a file with annotations
procedure showline:        show ticks and visits with one line
July 13, 2011; Gregg M. Townsend
This file is in the public domain.
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.

[ Summary entry | Source code ]


ipsort.icn: Program to sort Icon procedures

June 27, 1997; Ralph E. Griswold
This file is in the public domain.
   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

[ Summary entry | Source code ]


ipsplit.icn: Program to split Icon program into files

June 10, 1988; Ralph E. Griswold
This file is in the public domain.
   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.

[ Summary entry | Source code ]


ipxref.icn: Program to cross reference Icon program

June 14, 1994; Allan J. Anderson
This file is in the public domain.
   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.
____________________________________________________________

Bugs:  In some situations, the output is not properly formatted.

[ Summary entry | Source code ]


irsort.icn: Program to sort Icon record declaration

June 23, 2000; Ralph E. Griswold
This file is in the public domain.
   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.

[ Summary entry | Source code ]


irunerr.icn: Program to print Icon runtime errors

September 22, 1993; Robert J. Alexander
This file is in the public domain.
Program to list Icon runtime errors.

[ Summary entry | Source code ]


iseq.icn: Program to write sequence of integers

November 3, 1996; Ralph E. Griswold
This file is in the public domain.
This program generates integers in sequence.

The following options are supported:

     -b i    beginning integer; default 1
     -e i    ending integer; default no end
     -i i    increment; default 1
     -l i    limit on number of integers generated; default no limit

Large integer values are not supported.

[ Summary entry | Source code ]


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

May 11, 1999; Ralph E. Griswold
This file is in the public domain.
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.
____________________________________________________________

UNIX and the itokens meta-translator

[ Summary entry | Source code ]


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

November 7, 1997; Ralph E. Griswold
This file is in the public domain.
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.

[ Summary entry | Source code ]


istrip.icn: Program to strip comments from Icon program

March 29, 1992; Ralph E. Griswold
This file is in the public domain.
This program strips comments out of an Icon program. It also removes
empty lines and leading whitespace (see stripcom.icn).

[ Summary entry | Source code ]


itab.icn: Program to entab an Icon program

August 30, 1990; Robert J. Alexander
This file is in the public domain.
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.

[ Summary entry | Source code ]


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

August 3, 2000; Robert J. Alexander
This file is in the public domain.
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.

[ Summary entry | Source code ]


itrbksum.icn: Program to give summary of traceback

March 26, 2002; Ralph E. Griswold
This file is in the public domain.
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.

[ Summary entry | Source code ]


itrcfltr.icn: Program to filter trace output

July 14, 1997; Ralph E. Griswold
See also: options.icn
This file is in the public domain.
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

[ Summary entry | Source code ]


itrcsum.icn: Program to give summary of trace output

July 14, 1997; Ralph E. Griswold
This file is in the public domain.
This program provides a summary of Icon trace output.

[ Summary entry | Source code ]


iundecl.icn: Program to find undeclared Icon identifiers

August 14, 1996; Robert J. Alexander and Ralph E. Griswold
Requires: UNIX
This file is in the public domain.
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.

[ Summary entry | Source code ]


iversion.icn: Program to show icode version

April 28, 1994; Ralph E. Griswold
This file is in the public domain.
  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).

[ Summary entry | Source code ]


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

March 7, 1990; Ralph E. Griswold
This file is in the public domain.
   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 ... .

[ Summary entry | Source code ]


knapsack.icn: Program to fill a container

August 8, 1993; Anthony V. Hewitt
This file is in the public domain.
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.

[ Summary entry | Source code ]


krieg.icn: Program to play kriegspiel

August 14, 1996; David J. Slate
This file is in the public domain.
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.
____________________________________________________________

The version of the game implemented here was learned by the author
informally many years ago.  There may be other variations, and perhaps
the rules are actually written down somewhere in some book of games.

The game is usually played in a room with three chess boards set up on
separate tables.  The players sit at the two end tables facing away from
each other.  A third participant, the "monitor", acts as a referee and
scorekeeper and keeps track of the actual game on the middle board,
which is also out of sight of either player.  Since each player knows
only his own moves, he can only guess the position of the enemy pieces,
so he may place and move these pieces on his board wherever he likes.

To start the game, the "White" player makes a move on his board.  If the
move is legal, the monitor plays it on his board and invites "Black" to
make his response.  If a move attempt is illegal (because it leaves the
king in check or tries to move through an enemy piece, etc.), the
monitor announces that fact to both players and the moving player must
try again until he finds a legal move.  Thus the game continues until it
ends by checkmate, draw, or agreement by the players.  Usually the
monitor keeps a record of the moves so that the players can play the
game over at its conclusion and see what actually happened, which is
often quite amusing.

With no additional information provided by the monitor, the game is very
difficult but, surprisingly, still playable, with viable tactical and
strategic ideas.  Usually, however, the monitor gives some minimal
feedback to both players about certain events.  The locations of
captures are announced as well as the directions from which checks on
the kings originate.

Even with the feedback about checks and captures, a newcomer to
Kriegspiel might still think that the players have so little information
that they could do little more than shuffle around randomly hoping to
accidentally capture enemy pieces or checkmate the enemy king.  But in
fact a skilled player can infer a lot about his opponent's position and
put together plans with a good chance of success.  Once he achieves a
substantial material and positional advantage, with proper technique he
can usually exploit it by mopping up the enemy pieces, promoting pawns,
and finally checkmating the enemy king as he would in an ordinary chess
game.  In the author's experience, a skilled Kriegspiel player will win
most games against a novice, even if both players are equally matched at
regular chess.
____________________________________________________________

The implementation:

The functions of this program are to replace the human monitor, whose
job is actually fairly difficult to do without mistakes, to permit the
players to play from widely separate locations, to produce a machine-
readable record of the game, and to provide, if desired, a computer
opponent for a single player to practice and spar with.

When two humans play, each logs in to the same computer from a separate
terminal and executes his own copy of the program.  This requires a
multi-tasking, multi-user operating system.  For various reasons, the
author chose to implement Kriegspiel under UNIX, using named pipes for
inter-process communication.  The program has been tested successfully
under Icon Version 7.5 on a DecStation 3100 running Ultrix (a Berkeley-
style UNIX) and also under Icon Version 7.0 on the ATT UNIX-PC and
another System V machine, but unanticipated problems could be
encountered by the installer on other computers.  An ambitious user may
be able to port the program to non-UNIX systems such as Vax-VMS.  It may
also be possible to implement Kriegspiel on a non-multi-tasking system
such as MS-DOS by using separate computers linked via serial port or
other network.  See the "init" procedure for much of the system-
dependent code for getting user name, setting up communication files,
etc.

Two prospective opponents should agree on who is to play "white", make
sure they know each other's names, and then execute Kriegspiel from
their respective terminals.  The program will prompt each player for his
name (which defaults to his user or login name), his piece color, the
name of his opponent, whether he wishes to play in "totally blind" mode
(no capture or check information - not recommended for beginners), and
the name of the log file on which the program will leave a record of the
game (the program supplies a default in /tmp).  Each program will set up
some communication files and wait for the opponent's to show up.  Once
communication is established, each player will be prompted for moves and
given information as appropriate.  The online "help" facility documents
various additional commands and responses.

A player who wants a computer opponent should select "auto" as his
opponent's name.  Play then proceeds as with a human opponent.  "Auto"
is currently not very strong, but probably requires more than novice
skill to defeat.
____________________________________________________________

Known bugs and limitations:

No bugs are currently known in the areas of legal move generation,
board position updating, checkmate detection, etc., but it is still
possible that there are a few.

Some cases of insufficient checkmating material on both sides are
not detected as draws by the program.

In the current implementation, a player may not play two
simultaneous games under the same user name with the same piece color.

If the program is terminated abnormally it may leave a communication
pipe file in /tmp.

[ Summary entry | Source code ]


kross.icn: Program to show intersections of strings

May 9, 1989; Ralph E. Griswold
This file is in the public domain.
   This program procedure accepts pairs of strings on successive lines.
It diagrams all the intersections of the two strings in a common
character.

[ Summary entry | Source code ]


kwic.icn: Program to produce keywords in context

February 15, 1995; Stephen B. Wampler, modified by Ralph E. Griswold
This file is in the public domain.
   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".

[ Summary entry | Source code ]


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

November 25, 1996; Ralph E. Griswold
This file is in the public domain.
This program prepares information used for creating keyword-in-context
listings of the Icon program library.

[ Summary entry | Source code ]


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

April 17, 1996; Ralph E. Griswold
Requires:
This file is in the public domain.

[ Summary entry | Source code ]


labels.icn: Program to format mailing labels

December 30, 1991; Ralph E. Griswold
See also: address.doc, adllist.icn, adlfiltr.icn, adlcount.icn, adlcheck.icn, zipsort.icn
This file is in the public domain.
   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.

[ Summary entry | Source code ]


lam.icn: Program to laminate files

June 10, 1988; Thomas R. Hicks
This file is in the public domain.
   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.

[ Summary entry | Source code ]


latexidx.icn: Program to process LaTeX idx file

April 19, 1989; David S. Cargo
This file is in the public domain.
 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.

[ Summary entry | Source code ]


lc.icn: Program to count lines in file

July 19, 1994; Ralph E. Griswold
This file is in the public domain.
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.

[ Summary entry | Source code ]


lcfile.icn: Program to convert file names to lowercase

June 11, 2001; Ralph E. Griswold
Requires: UNIX
This file is in the public domain.
This program converts file names to lowercase letters.  File names to
convert are given in standard input.

[ Summary entry | Source code ]


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

February 25, 2003; Ralph E. Griswold
Requires: UNIX
This file is in the public domain.
This program converts files named on the command line to all lowercase
names.  Blanks are converted to underscores.

[ Summary entry | Source code ]


limitf.icn: Program to limit throughput

September 17, 1998; Ralph E. Griswold
This file is in the public domain.
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).

[ Summary entry | Source code ]


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

August 19, 1993; Ralph E. Griswold
See also: lindrec.icn
This file is in the public domain.
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.

[ Summary entry | Source code ]


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

May 10, 2006; Ralph E. Griswold
This file is in the public domain.
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.
____________________________________________________________

See linden.dat for an example of input data.

See also linden.icn for a graphics version.

[ Summary entry | Source code ]


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

February 18, 1995; Ralph E. Griswold
This file is in the public domain.
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

[ Summary entry | Source code ]


link2url.icn: Program to convert links to URLs

September 1, 1998; Ralph E. Griswold
This file is in the public domain.
This program takes HTML links from standard input, strips off the
tags and related material, and write the resulting URLs to standard
output.

[ Summary entry | Source code ]


lisp.icn: Program to interpret LISP programs

April 16, 2012; Stephen B. Wampler
This file is in the public domain.
   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.

[ Summary entry | Source code ]


lister.icn: Program to list filess

December 28, 1995; Beppe Pavoletti
This file is in the public domain.
This program lists files.  Note that the language is in Italian.
____________________________________________________________

PROGRAMMA LIST visualizzazione e stampa file

Autore: Beppe Pavoletti
        Via Trieste 12 I-15011
        ACQUI TERME AL

Tel. 0144.320218

Versione 2.0   26.12.1993

[ Summary entry | Source code ]


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

September 17, 1998; Ralph E. Griswold
This file is in the public domain.
The files to be included are listed in standard input.  There is no
check that the files actually exist.

[ Summary entry | Source code ]


listviz.icn: Program to visualize lists

August 14, 1996; Beppe Pavoletti
This file is in the public domain.
This program visualizes lists.  Note that the language is Italian.
____________________________________________________________

PROGRAMMA LIST visualizzazione e stampa file

Autore: Beppe Pavoletti
        Via Trieste 12 I-15011
        ACQUI TERME AL

Tel. 0144.320218

Versione 2.0   26.12.1993

[ Summary entry | Source code ]


literat.icn: Program to manage literature information

March 26, 2002; Matthias Heesch
Requires: large-integer arithmetic, ANSI terminal support
This file is in the public domain.
Database system to manage information concerning literature.
____________________________________________________________

           Written by: Dr. Matthias Heesch
       Department of Protestant Theology (FB 02)
            Johannes Gutenberg University
     Saarstrasse 21 / D-W-6500 Mainz 1 / Germany
____________________________________________________________

Written and tested under: DR/MS-DOS, using ansi.sys
____________________________________________________________

See the comment lines concerning the single user defined
functions if you want to use them separately. Note that all screen
access assumes ansi.sys to be installed.

Since arguments to the seek() function may be long integers,
long-integer support is required.

The program uses standard files literat.fil, literat2.fil and
adress.fil to store its data on the disk. It has a predefined
structure of the items and predefined field labels to make it easy
to use and to cut down the source code length.for users having some
knowledge of the Icon language it shouldn't be difficult to
change the program. In this case the item length (now 846 byte)
the option lists in menue() and the field label list have to be
modified. The main changes then will concern user defined
function edit_item() where the number of fields within an item
is decided by *labels. In function in_itemm() the number of dummy
field separators has to be equal to the amount of fields desired.
(items := list(200,"##" if two fields are desired). Within the
other functions only the amount of bytes for a whole item within
reads() and seek() operation has to be changed accordingly. Note
that "literat"'s editor in its present version isn't able to scroll.

See the description (comment lines) of user defined function
line() for details of the editing facilities.

The menue accepts input by <arrow up/dn> and the lower case short
hand key of every option. The selected option has to be activated
by <ret>.

iNPUT: function to update an existing file literat.dat. When moving
the cursor out of the actual item, the last or following item will
be displayed and is available for the editing process. Input treats
literat.dat as a sequential file. Only the items to be added to the
existing file are in the computer's memory. This fastens the option
to switch between the (new) items. Otherwise it would have been
necessary to load the whole literat.dat into the RAM or to load
every new item from the disk. The first would consume too much
memory with the result of potential loss of new items, the second
would cost much time. In one session "literat" can accept no more
than 200 new items.

tURN_OVER_ITEMS: literat.dat can be viewed and edited item by item
moving the cursor out of the actual item causes the next/last item
to be displayed. The edited items are written to file literat2.fil

aDRESS file: type words to be indicated. If they are found, the
item numbers of their occurrence will be recorded in file adress.fil.
Moving the cursor out of the editor causes the indicating
process to start. New items to adress.fil are simply added to the
file. Therefore changes of existing material in adress.fil have to
be made by creating a new adress.fil.

qUERY: searches item using the information in adress.fil. You are
prompted to type a word and if it's found in adress.fil the
programm will use the item numbers to compute arguments to the
seek()-function and then read the item. After viewing and if
desired editing the item it will be written to file literat2.fil.

dEL: prompts for an item number and removes the corresponding item.
the file then is written to literat2.fil, literat.fil remains
as it was.

AlPHA: alphabetical sorting, sorted file written to literat2.fil.

eND: return to the operating system.
____________________________________________________________

Important message to the user: everybody who will find and remove
a bug or add any improvement to the program is kindly encouraged
to send a copy to the above address.
____________________________________________________________

Note:  Clerical edits were made to this file by the Icon Project.
       It's possible they introduced errors.

[ Summary entry | Source code ]


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

June 12, 1999; Ralph E. Griswold
This file is in the public domain.
This program reads a file from standard input and writes out the
lengths of the shortest and longest lines in it.

[ Summary entry | Source code ]


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

December 13, 1985; Stephen B. Wampler
Requires: UNIX
This file is in the public domain.
   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.
____________________________________________________________

Notes:

   The size of the last region in a symbol class is suspect and is
usually given as rem.

   Output is not particularly exciting on a stripped file.

[ Summary entry | Source code ]


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

November 25, 1992; Ralph E. Griswold
This file is in the public domain.
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.

[ Summary entry | Source code ]


lower.icn: Program to map file names to lowercase

January 6, 1995; Ralph E. Griswold
Requires: UNIX
This file is in the public domain.
This program maps the names of all files in the current directory to
lowercase.

[ Summary entry | Source code ]


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

November 25, 1996; Ralph E. Griswold
Requires: Input from UNIX ls -l
This file is in the public domain.
This program summarizes file sizes give by the UNIX ls -l command.

It probably platform dependent.

[ Summary entry | Source code ]


lsysmap.icn: Program to map L-system symbols

June 18, 1998; Ralph E. Griswold
This file is in the public domain.
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.

[ Summary entry | Source code ]


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

September 18, 1998; Ralph E. Griswold
This file is in the public domain.
This program maps the Macintosh characters for quotation and various
minus signs into their ASCII equivalents.

[ Summary entry | Source code ]


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

May 2, 2001; Richard L. Goerwitz
This file is in the public domain.
   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).

[ Summary entry | Source code ]


mapcolrs.icn: Program to map colors in lists

August 3, 2000; Ralph E. Griswold
This file is in the public domain.
This program maps colors in lists.

This is a work in progress.

[ Summary entry | Source code ]


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

August 17, 1998; Ralph E. Griswold
This file is in the public domain.
This program displays the signature of a MIDI file.

[ Summary entry | Source code ]


missile.icn: Program to play missile command game

June 14, 1994; Chris Tenaglia
This file is in the public domain.
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!

[ Summary entry | Source code ]


miu.icn: Program to generate strings from MIU system

January 3, 1994; Cary A. Coutant, modified by Ralph E. Griswold
This file is in the public domain.
   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.

[ Summary entry | Source code ]


mkpasswd.icn: Program to make passwords

August 14, 1996; Jere K{pyaho
This file is in the public domain.
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.

[ Summary entry | Source code ]


monkeys.icn: Program to generate random text

September 7, 1990; Stephen B. Wampler
Contributors: Ralph E. Griswold and Alan Beale
This file is in the public domain.
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

[ Summary entry | Source code ]


morse.icn: Program to convert string to Morse code

August 14, 1996; Ralph E. Griswold and Robert J. Alexander
This file is in the public domain.
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.

[ Summary entry | Source code ]


mr.icn: Program to read mail

November 19, 1997; Ronald Florence
This file is in the public domain.
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.

[ Summary entry | Source code ]


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

June 23, 2000; Gregg M. Townsend
Requires: UNIX, zip program
This file is in the public domain.
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.

[ Summary entry | Source code ]


mtf3.icn: Program to map tar file

June 3, 1991; Richard Goerwitz
This file is in the public domain.
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!

[ Summary entry | Source code ]


newicon.icn: Program to produce new Icon program file

March 26, 2002; Ralph E. Griswold
Requires: system(), vi(1)
This file is in the public domain.
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().

[ Summary entry | Source code ]


newsrc.icn: Program to organize UNIX .newsrc file

April 1, 1993; Alan D. Corre
This file is in the public domain.
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.

[ Summary entry | Source code ]


nim.icn: Program to play the game of nim

June 14, 1994; Jerry Nowlin
This file is in the public domain.
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.

[ Summary entry | Source code ]


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

December 30, 1991; Richard L. Goerwitz
Requires: UNIX or MS-DOS See also: yescr.icn
This file is in the public domain.
  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.

[ Summary entry | Source code ]


noise.icn: Program to generate random noise

November 3, 2003; Gregg M. Townsend
This file is in the public domain.
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.

[ Summary entry | Source code ]


normalize.icn: Program to normalize numeric channel

January 21, 1999; Ralph E. Griswold
This file is in the public domain.
This program reads numbers, one per line, from standard input and
writes them out normalized so that the largest is 1.0.

[ Summary entry | Source code ]


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

September 23, 1996; Ralph E. Griswold
Requires: system(), vi(1), UNIX
This file is in the public domain.
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.

[ Summary entry | Source code ]


pack.icn: Program to package multiple files

July 1, 1997; Ralph E. Griswold
See also: unpack.icn
This file is in the public domain.
   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.

[ Summary entry | Source code ]


paginate.icn: Program to insert formfeeds

September 28, 1992; Paul Abrahams
This file is in the public domain.
This program processes a document text file, inserting formfeeds
at appropriate places.

[ Summary entry | Source code ]


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

May 31, 1994; Ralph E. Griswold
This file is in the public domain.
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.

[ Summary entry | Source code ]


parens.icn: Program to produce random balanced strings

March 26, 2002; Ralph E. Griswold
This file is in the public domain.
   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.

[ Summary entry | Source code ]


pargen.icn: Program to generate context-free parser

March 31, 1992; Ralph E. Griswold
This file is in the public domain.
   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.
____________________________________________________________

Limitations:

   Left recursion in the grammar may cause the parser to loop.
There is no check that all nonterminal symbols that are referenced
are defined or that there may be duplicate definitions.
____________________________________________________________

Reference:

   The Icon Programming Language, Second Edition, Ralph E. and Madge T.
   Griswold, Prentice-Hall, 1990, pp. 180-187.
____________________________________________________________

Output links recog, matchlib

See also: recog.icn, matchlib.icn, and parscond.icn

[ Summary entry | Source code ]


parse.icn: Program to parse simple statements

February 18, 1996; Kenneth Walker
This file is in the public domain.
This program parses simple statements.

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

[ Summary entry | Source code ]


parsex.icn: Program to parse arithmetic expressions

June 10, 1988; Cheyenne Wills
This file is in the public domain.
 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')

[ Summary entry | Source code ]


patchu.icn: Program to implement UNIX-like patch

June 18, 1990; Rich Morin
Requires: co-expressions
This file is in the public domain.
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.

[ Summary entry | Source code ]


pbkdump.icn: Program to dump HP95 phone book file

August 14, 1996; Robert J. Alexander
See also: pbkform.icn, pbkutil.icn, abkform.icn
This file is in the public domain.
Program to dump data from a HP95 phone book (pbk) file.

[ Summary entry | Source code ]


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

December 12, 1995; Ralph E. Griswold
This file is in the public domain.
This program lists the prime factors of integers given in
standard input.

[ Summary entry | Source code ]


polydemo.icn: Program to demonstrate polynomial library

May 23, 1994; Erik Eid
This file is in the public domain.
    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

[ Summary entry | Source code ]


post.icn: Program to post news

August 14, 1996; Ronald Florence
This file is in the public domain.
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.
____________________________________________________________

Bugs: Newsgroup validation assumes the `active' file is sorted.
      Non-UNIX sites need hardcoded system information.

[ Summary entry | Source code ]


press.icn: Program to archive files

November 14, 1991; Robert J. Alexander
This file is in the public domain.
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.
____________________________________________________________

Instructions for use are summarized in "help" procedures that follow.

[ Summary entry | Source code ]


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

November 22, 1996; Ralph E. Griswold
This file is in the public domain.
This program discards the first i values in input, given by -n i; default
0.

[ Summary entry | Source code ]


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

November 22, 1996; Ralph E. Griswold
This file is in the public domain.
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.

[ Summary entry | Source code ]


procwrap.icn: Program to produce Icon procedure wrappers

September 29, 1994; Ralph E. Griswold
This file is in the public domain.
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.

[ Summary entry | Source code ]


proto.icn: Program to show Icon syntactic forms

January 3, 1993; Ralph E. Griswold
This file is in the public domain.
   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.
____________________________________________________________

Program note:

   This program is divided into procedures to avoid overflow with
default values for Icon's translator and linker.

[ Summary entry | Source code ]


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

September 21, 1999; Gregg M. Townsend
This file is in the public domain.
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.

[ Summary entry | Source code ]


pt.icn: Program to produce parse table generator

December 10, 1988; Deeporn H. Beardsley
This file is in the public domain.
See pt.man for a description of functionality as well as input and
output format.

[ Summary entry | Source code ]


puzz.icn: Program to create word search puzzle

February 18, 1996; Chris Tenaglia
This file is in the public domain.
This program creates word search puzzles.

[ Summary entry | Source code ]


qei.icn: Program to evaluate Icon expressions interactively

March 26, 2002; William H. Mitchell and Ralph E. Griswold
Requires: co-expressions and system()
This file is in the public domain.
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.
____________________________________________________________

"qei" is derived from the Latin "quod erat inveniendum" -- "which was
to be found out".

[ Summary entry | Source code ]


qt.icn: Program to announce time in English

November 26, 1996; Robert J. Alexander
This file is in the public domain.
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.

[ Summary entry | Source code ]


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

June 10, 1988; Stephen B. Wampler
This file is in the public domain.
   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.

[ Summary entry | Source code ]


ranstars.icn: Program to display star field

March 2, 1996; Ralph E. Griswold
Requires: co-expressions, ANSI terminal
This file is in the public domain.
   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.

[ Summary entry | Source code ]


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

March 7, 2000; Gregg M. Townsend
This file is in the public domain.
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...

[ Summary entry | Source code ]


recgen.icn: Program to generate context-free recognizer

January 28, 1991; Ralph E. Griswold
See also: pargen.icn
This file is in the public domain.
   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.
____________________________________________________________

Limitations:

   Left recursion in the grammar may cause the recognizer to loop.
There is no check that all nonterminal symbols that are referenced
are defined or for duplicate definitions.
____________________________________________________________

Reference:

   The Icon Programming Language, Second Edition, Ralph E. and Madge T.
   Griswold, Prentice-Hall, 1990. pp. 180-187.

[ Summary entry | Source code ]


repeats.icn: Program to repeat stream

January 21, 1999; Ralph E. Griswold
This file is in the public domain.
This program repeat the input stream.  The following options are
supported:

     -l i    limit on length of input stream; default 1000.
     -r i    number of time input stream is repeated; default no limit.

Note that the input stream must be limited, since it is stored internally.

[ Summary entry | Source code ]


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

March 8, 1991; Ronald Florence
This file is in the public domain.
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.

[ Summary entry | Source code ]


repro.icn: Program to self-reproduce

August 4, 2000; Kenneth Walker
This file is in the public domain.
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.

[ Summary entry | Source code ]


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

August 11, 1999; Ralph E. Griswold
This file is in the public domain.
This program reverses the order of lines in a file.  Beware of large
files.

[ Summary entry | Source code ]


revsort.icn: Program to sort strings backwards

September 5, 1995; Ralph E. Griswold
This file is in the public domain.
This program sorts strings with characters in reverse order.

[ Summary entry | Source code ]


roffcmds.icn: Program to list roff commands and macros

June 10, 1988; Ralph E. Griswold
This file is in the public domain.
   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.

[ Summary entry | Source code ]


rsg.icn: Program to generate randomly selected sentences

March 26, 2002; Ralph E. Griswold
This file is in the public domain.
   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.
____________________________________________________________

   The program works interactively, allowing the user to build,
test, modify, and save grammars. Input to rsg consists of various
kinds of specifications, which can be intermixed:

   Productions define nonterminal symbols in a syntax similar to
the rewriting rules of BNF with various alternatives consisting
of the concatenation of nonterminal and terminal symbols.  Gen-
eration specifications cause the generation of a specified number
of sentences from the language defined by a given nonterminal
symbol.  Grammar output specifications cause the definition of a
specified nonterminal or the entire current grammar to be written
to a given file.  Source specifications cause subsequent input to
be read from a specified file.

   In addition, any line beginning with # is considered to be a
comment, while any line beginning with = causes the rest of that
line to be used subsequently as a prompt to the user whenever rsg
is ready for input (there normally is no prompt). A line consist-
ing of a single = stops prompting.

Productions: Examples of productions are:

        <expr>::=<term>|<term>+<expr>
        <term>::=<elem>|<elem>*<term>
        <elem>::=x|y|z|(<expr>)

Productions may occur in any order. The definition for a nonter-
minal symbol can be changed by specifying a new production for
it.

   There are a number of special devices to facilitate the defin-
ition of grammars, including eight predefined, built-in nontermi-
nal symbols:
   symbol   definition
   <lb>     <
   <rb>     >
   <vb>     |
   <nl>     newline
   <>       empty string
   <&lcase> any single lowercase letter
   <&ucase> any single uppercase letter
   <&digit> any single digit

In addition, if the string between a < and a > begins and ends
with a single quotation mark, it stands for any single character
between the quotation marks. For example,

        <'xyz'>

is equivalent to

        x|y|z

Generation Specifications: A generation specification consists of
a nonterminal symbol followed by a nonnegative integer. An exam-
ple is

        <expr>10

which specifies the generation of 10 <expr>s. If the integer is
omitted, it is assumed to be 1. Generated sentences are written
to standard output.

Grammar Output Specifications: A grammar output specification
consists of a nonterminal symbol, followed by ->, followed by a
file name. Such a specification causes the current definition of
the nonterminal symbol to be written to the given file. If the
file is omitted, standard output is assumed. If the nonterminal
symbol is omitted, the entire grammar is written out. Thus,

        ->

causes the entire grammar to be written to standard output.

Source Specifications: A source specification consists of @ fol-
lowed by a file name.  Subsequent input is read from that file.
When an end of file is encountered, input reverts to the previous
file. Input files can be nested.

Options: The following options are available:

     -s n Set the seed for random generation to n.

     -r   In the absence of -s, set the seed to 0 for repeatable
          results.  Otherwise the seed is set to a different value
          for each run (as far as this is possible). -r is equivalent
          to -s 0.

     -l n Terminate generation if the number of symbols remaining
          to be processed exceeds n. The default is limit is 1000.

     -t   Trace the generation of sentences. Trace output goes to
          standard error output.

Diagnostics: Syntactically erroneous input lines are noted but
are otherwise ignored.  Specifications for a file that cannot be
opened are noted and treated as erroneous.

   If an undefined nonterminal symbol is encountered during gen-
eration, an error message that identifies the undefined symbol is
produced, followed by the partial sentence generated to that
point. Exceeding the limit of symbols remaining to be generated
as specified by the -l option is handled similarly.

Caveats: Generation may fail to terminate because of a loop in
the rewriting rules or, more seriously, because of the progres-
sive accumulation of nonterminal symbols. The latter problem can
be identified by using the -t option and controlled by using the
-l option. The problem often can be circumvented by duplicating
alternatives that lead to fewer rather than more nonterminal sym-
bols. For example, changing

        <term>::=<elem>|<elem>*<term>

to

        <term>::=<elem>|<elem>|<elem>*<term>

increases the probability of selecting <elem> from 1/2 to 2/3.

   There are many possible extensions to the program. One of the
most useful would be a way to specify the probability of select-
ing an alternative.

[ Summary entry | Source code ]


ruler.icn: Program to write a character ruler

December 5, 1989; Robert J. Alexander
This file is in the public domain.
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.

[ Summary entry | Source code ]


sample.icn: Program to "sample" input stream

January 21, 1999; Ralph E. Griswold
This file is in the public domain.
This program filters the input stream, producing every ith
value, starting at 1.  i is given as a command-line argument; default 0.

[ Summary entry | Source code ]


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

January 20, 1999; Ralph E. Griswold
This file is in the public domain.
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.

[ Summary entry | Source code ]


scramble.icn: Program to scramble a document

June 14, 1994; Chris Tenaglia
This file is in the public domain.
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.

[ Summary entry | Source code ]


setmerge.icn: Program to combine sets of text items

May 31, 1994; Gregg M. Townsend
This file is in the public domain.
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

[ Summary entry | Source code ]


shar.icn: Program to create UNIX shell archive

May 6, 1992; Robert J. Alexander
This file is in the public domain.
Program to create Bourne shell archive of text files.

Usage: shar text_file...

[ Summary entry | Source code ]


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

November 25, 1992; Ralph E. Griswold
This file is in the public domain.
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.

[ Summary entry | Source code ]


shuffile.icn: Program to shuffle lines in a file

May 12, 1996; Ralph E. Griswold
This file is in the public domain.
   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.

[ Summary entry | Source code ]


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

December 10, 2002; Gregg M. Townsend
This file is in the public domain.
This program outputs in random order the lines of one or more files.
The input data must fit in memory.

usage:  shuffle [file...]

[ Summary entry | Source code ]


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

September 14, 1990; Frank J. Lhota
This file is in the public domain.
   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.

[ Summary entry | Source code ]


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

June 27, 1998; Ralph E. Griswold
This file is in the public domain.
The maximum line length is given on the command line, as in

     slice 60 < foo > baz

[ Summary entry | Source code ]


snake.icn: Program to play the snake game

March 26, 2002; Richard L. Goerwitz
Requires: UNIX (MS-DOS is okay, if you replace itlib with itlibdos.icn)
This file is in the public domain.
    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.
____________________________________________________________

Bugs:  Most magic cookie terminals just won't work.  Terminal really
needs reverse video (it will work without, but won't look as cute).

[ Summary entry | Source code ]


solit.icn: Program to play solitaire

November 25, 1996; Jerry Nowlin
Contributors: Phillip L. Thomas and Ralph E. Griswold
Requires: keyboard functions
This file is in the public domain.
   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.
____________________________________________________________

Note:

   The command-line argument, which defaults to support for the VT100,
determines the screen driver.  For MS-DOS computers, the ANSI.SYS driver
is needed.

[ Summary entry | Source code ]


sortname.icn: Program to order by last name

February 18, 1996; Ralph E. Griswold
This file is in the public domain.
This program sorts a list of person's names by the last names.

[ Summary entry | Source code ]


splitlit.icn: Program to create string literal

September 15, 1993; Ralph E. Griswold
This file is in the public domain.
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

[ Summary entry | Source code ]


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

June 6, 1999; Gregg M. Townsend
This file is in the public domain.
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)

[ Summary entry | Source code ]


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

June 12, 1995; Ralph E. Griswold
This file is in the public domain.
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.

[ Summary entry | Source code ]


strimlen.icn: Program to produce lengths of string images

February 25, 2003; Ralph E. Griswold
This file is in the public domain.
This program is a filter that reads images of Icon strings from standard
input and writes the lengths of the strings to standard output.

[ Summary entry | Source code ]


strpsgml.icn: Program to strip/translate SGML tags

November 19, 1997; Richard L. Goerwitz
This file is in the public domain.
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.

[ Summary entry | Source code ]


tabexten.icn: Program to tabulate file extensions

March 10, 1998; Ralph E. Griswold
This file is in the public domain.
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.

[ Summary entry | Source code ]


tablc.icn: Program to tabulate characters in a file

June 10, 1988; Ralph E. Griswold
This file is in the public domain.
   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.

[ Summary entry | Source code ]


tablw.icn: Program to tabulate words in a file

December 27, 1989; Ralph E. Griswold
This file is in the public domain.
   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.

[ Summary entry | Source code ]


tabulate.icn: Program to tabulate lines in a file

February 28, 1999; Ralph E. Griswold
This file is in the public domain.
This program produces a tabulation showing how many times each
line of a file occurs.

[ Summary entry | Source code ]


textcnt.icn: Program to tabulate properties of text file

May 2, 2001; Ralph E. Griswold
This file is in the public domain.
   This program tabulates the number of characters, "words", and
lines in standard input and gives the maximum and minimum line length.

[ Summary entry | Source code ]


textcvt.icn: Program to convert text file formats

November 21, 1996; Robert J. Alexander
This file is in the public domain.
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.

[ Summary entry | Source code ]


toktab.icn: Program to summarize Icon token counts

June 21, 1994; Ralph E. Griswold
This file is in the public domain.
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

[ Summary entry | Source code ]


trim.icn: Program to trim lines in a file

December 26, 1998; Ralph E. Griswold
This file is in the public domain.
   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.

[ Summary entry | Source code ]


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

August 14, 1996; Chris Tenaglia
This file is in the public domain.
This program plays the game of tic-tac-toe.

[ Summary entry | Source code ]


turing.icn: Program to simulate a Turing machine

November 14, 1994; Gregg M. Townsend
This file is in the public domain.
   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.

[ Summary entry | Source code ]


unclog.icn: Program to reformat CVS log output

August 14, 2007; Gregg M. Townsend
This file is in the public domain.
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.

[ Summary entry | Source code ]


unique.icn: Program to delete identical adjacent lines

October 21, 1991; Anthony V. Hewitt, modified by Bob Alexander
This file is in the public domain.
Filters out identical adjacent lines in a file.

[ Summary entry | Source code ]


unpack.icn: Program to unpackage files

May 27, 1989; Ralph E. Griswold
See also: pack.icn
This file is in the public domain.
   This program unpackages files produced by pack.icn.  See that program
for information about limitations.

[ Summary entry | Source code ]


upper.icn: Program to map file names to uppercase

March 10, 1995; Ralph E. Griswold
Requires: UNIX
This file is in the public domain.
This program maps the names of all files in the current directory to
uppercase.

[ Summary entry | Source code ]


url2link.icn: Program to convert bookmarked URLs to link references

October 19, 1998; Ralph E. Griswold
This file is in the public domain.
This program reads URLs from standard input and writes HTML links to
standard output.

[ Summary entry | Source code ]


utrim.icn: Program to remove unneeded procs from ucode

August 7, 1993; Gregg M. Townsend
This file is in the public domain.
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.

[ Summary entry | Source code ]


verse.icn: Program to generate bizarre verses

May 26, 1992; Chris Tenaglia
This file is in the public domain.
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.

[ Summary entry | Source code ]


versum.icn: Program to produce versum sequence

August 12, 1995; Ralph E. Griswold
This file is in the public domain.
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.

[ Summary entry | Source code ]


vnq.icn: Program to display solutions to n-queens problem

August 14, 1996; Stephen B. Wampler
This file is in the public domain.
This program displays solutions to the n-queens problem.

[ Summary entry | Source code ]


vrepl.icn: Program to replicate input lines

January 14, 1999; Ralph E. Griswold
This file is in the public domain.
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.

[ Summary entry | Source code ]


weblinks.icn: Program to check links in HTML files

October 6, 2010; Gregg M. Townsend
Requires: Unix, dynamic loading
This file is in the public domain.
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.
____________________________________________________________

By design, only local files are scanned.  Only an existence check is
performed for HTTP: links.  Validation of HTTP: links is aided by
caching and subject to speed limits; see "vhttp.icn" for details.

Remote links are checked by sending an HTTP "HEAD" request.
Unfortunately, some sites respond with "Server Error" or even with
snide remarks like "Because I felt like it".  These are reported
as errors and must be inspected manually.

NOTE:  if the environment variable USER is set, as it usually is,
then "From: $USER@hostname" is sent as part of each remote inquiry
in order to identify the source.  This is standard etiquette for
automated checkers.  If USER is not set, but LOGNAME is, then
$LOGNAME is used.

Limitations:
   url(...) links within embedded stylesheets are not recognized.
   FTP:, MAILTO:, and other link types are not validated.
   Files are checked recursively only if named *.htm*.
   Proper file permission (for web export) is not checked.

The common error of failing to put a trailing slash on a directory
specification results in a "453 Is A Directory" error message for a
local file or, typically, a "301 Moved Permanently" message for a
remote file.
____________________________________________________________

usage:   weblinks [options] file...

-R      follow file links recursively
        (http links are never followed recursively)

-t      trace files as visited

-s      report successes as well as problems

-v      report tracing and successes, if selected, more verbosely

-i      invert output (sort by referencing page, not by status)

-r root
        specify starting point for file names beginning with "/"
        (e.g. -r /cs/www).  This is needed if such references are
        to be followed or checked.  If a root is specified it
        affects all file specifications including those on the
        command line.

-h home
        specify starting point for file names beginning with "/~".

-p prefix[,prefix...]
        prune (don't check) files beginning with given prefix

-b prefix
        specify bounds for files scanned:  do not scan files
        that do not begin with prefix.  Default bounds are
        directory of last file name.  For example,
                weblinks /foo/bar /foo/baz
        implies "-b /foo/".

If the environment variable WEBLINKS_INIT is set, its whitespace-
separated words are prepended to the explicit command argument list.
____________________________________________________________

Examples (all assuming a web area rooted at /cs/www)

        To check one new page:
        weblinks -r /cs/www  /icon/books.htm

        To check a personal hierarchy, with tracing:
        setenv WEBLINKS_INIT "-r /cs/www -h /cs/www/people"
        weblinks -R -t /~gmt/

        To check with pruning:
        weblinks -R -t -r /cs/www -p /icon/library /icon/index.htm

[ Summary entry | Source code ]


what.icn: Program to identify source-code information

May 2, 2001; Phillip Lee Thomas
Requires: Tested with DOS, AIX UNIX
This file is in the public domain.
Writes all strings beginning with "@" followed by "(#)"
    and ending with null, newline, quotes, greater-than
    or backslash. Follows UNIX what conventions.

[ Summary entry | Source code ]


when.icn: Program to show file age

August 14, 1996; Chris Tenaglia
Requires: UNIX
This file is in the public domain.
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!

[ Summary entry | Source code ]


wshfdemo.icn: Program to demonstrate weighted shuffle procedure

May 23, 1994; Erik Eid
This file is in the public domain.
    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.

[ Summary entry | Source code ]


xtable.icn: Program to show character code translations

July 20, 1991; Robert J. Alexander, modified by Alan Beale
This file is in the public domain.
Program to print various character translation tables.  See
procedure help() for the capabilities.

[ Summary entry | Source code ]


yahtz.icn: Program to play yahtzee

March 3, 1996; Chris Tenaglia
This file is in the public domain.
Modified by Richard Goerwitz with corrections by Phillip Lee Thomas
____________________________________________________________

This hacked version will run under UNIX, and under DOS as well.  It
should run out of the box on DOS as long as you stay in the current
directory.  See the README file.

This is a test version!!  In accordance with the author's wishes,
I'd like to make it clear that I've altered all the screen I/O
routines, and have removed characters peculiar to VT terminals.
I've tried to keep intact the author's indentation and brace style.
Changes, where present, have been indicated by my initials.  The
IPL-style header was added by me.

-Richard Goerwitz.

[ Summary entry | Source code ]


yescr.icn: Program to convert UNIX files to DOS format

December 30, 1991; Richard L. Goerwitz
Requires: UNIX or MS-DOS See also: nocr.icn
This file is in the public domain.
  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.

[ Summary entry | Source code ]


zipsort.icn: Program to sort mailing labels by ZIP code

November 17, 1994; Ralph E. Griswold
This file is in the public domain.
   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.

[ Summary entry | Source code ]


Program Library Page | Icon Home Page