News flash: I'm going to Australia in February, so this Web site may be switched off at any time.


Creating an Icon list with specific contents

To create a list in the Icon language, simply enclose the elements of the list in square brackets, separated by commas. For example, this expression sets the variable ``flapper'' to a list with two elements, the integer 23 and the string "skiddoo":

    flapper  :=  [ 23, "skiddoo" ];
As another example, this expression sets the variable ``perfectPeople'' to an empty list:
    perfectPeople  :=  [ ];
Here, the variable ``array'' is set to a list containing two lists of three integers each:
    array  :=  [ [1, 3, 5], [2, 4, 6] ];

If you want to set up a list with a lot of elements all at once, see creating a list of a fixed size.


Next: Creating an Icon list of a fixed size
See also: Using the Icon programming language
Previous: Using the list type in Icon

John W. Shipman, john@nmt.edu