Syntax of integer lists

Purpose

Integer lists are used in a wide variety of contexts, e.g. in the preprocessor repeat directive. This web page documents the syntax of integer lists.

Note: in some contexts elements of the list are real numbers, not integers. The syntax is the same for real numbers.

Integer lists consist of a sequence of strings separated by commas:

       strn1,strn2,...


Each of the   strn1, strn2, …   can assume one of the following three forms:

1. a single integer or algebraic expression

2. two integer expressions separated by a colon, viz

low:high


gets expanded into

low, low+1, low+2, ... high

3. Three integer expressions separated by colons, viz

low:high:step


gets expanded into:

low, low+step, low+2*step, ... high

4. (Extension, applicable only in some contexts). The dup tag:

dup=#

duplicates the entire list to this point, and # is added to the duplicate elements. Thus the list doubles in size.

Examples

  5+1             becomes a single number, 6.
5+1:8+2         becomes a sequence of numbers, 6 7 8 9 10
5+1:8+2:2       becomes a sequence of numbers, 6 8 10
1:4,7:11        becomes the sequence 1 2 3 4  7 8 9 10 11

5,6,8,dup=16  becomes 5 6 8  21 22 24  (where applicable)


Note:  slatsm/mkilst.f contains the source code for generating integer lists.