indices.icn: Procedure to produce indices

procedure indices:         generate indices

link indices
June 2, 1998; Ralph E. Griswold
This file is in the public domain.

indices(spec, last)
                produces a list of the integers given by the
                specification spec, which is a common separated list
                of either positive integers or integer spans, as in

                        "1,3-10, ..."

                If last is specified, it it used for a span of
                the form "10-".

                In an integer span, the low and high values need not
                be in order.  For example, "1-10" and "10-1"
                are equivalent.  Similarly, indices need not be
                in order, as in "3-10, 1, ..."

                And empty value, as in "10,,12" is ignored.

                indices() fails if the specification is syntactically
                erroneous or if it contains a value less than 1.

Source code | Program Library Page | Icon Home Page