Full Documentation: Basic Programs

Library version 9.4.3



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

May 31, 1994; 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.