Icon (programming Language) - Other Structures

Other Structures

Icon also allows the user to easily construct their own lists (or arrays):

aCat :=

The items within a list can be of any sort, including other structures. To quickly build larger lists, Icon includes the list generator; i := list(10, "word") generates a list containing 10 copies of "word".

Like arrays in other languages, Icon allows items to be looked up by position, e.g., weight := aCat.

The bang-syntax, e.g., every write(!aCat), will print out four lines, each with one element.

Icon includes stack-like functions, push and pop to allow them to form the basis of stacks and queues.

Icon also includes functionality for sets and tables (known as hashes, associative arrays, dictionaries, etc.):

symbols := table(0) symbols := 1 symbols := 2

This code creates a table that will use zero as the default value of any unknown key. It then adds two items into it, with the keys "there" and "here", and values 1 and 2.

Read more about this topic:  Icon (programming Language)

Famous quotes containing the word structures:

    If there are people who feel that God wants them to change the structures of society, that is something between them and their God. We must serve him in whatever way we are called. I am called to help the individual; to love each poor person. Not to deal with institutions. I am in no position to judge.
    Mother Teresa (b. 1910)

    The American who has been confined, in his own country, to the sight of buildings designed after foreign models, is surprised on entering York Minster or St. Peter’s at Rome, by the feeling that these structures are imitations also,—faint copies of an invisible archetype.
    Ralph Waldo Emerson (1803–1882)