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

Source code | Program Library Page | Icon Home Page