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:
“It is clear that all verbal structures with meaning are verbal imitations of that elusive psychological and physiological process known as thought, a process stumbling through emotional entanglements, sudden irrational convictions, involuntary gleams of insight, rationalized prejudices, and blocks of panic and inertia, finally to reach a completely incommunicable intuition.”
—Northrop Frye (b. 1912)
“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)