next | previous | forward | backward | up | top | index | toc | Macaulay2 web site
VisibleList > List

List -- the class of all lists -- {...}

Description

Lists in Macaulay2 consist of elements of any type, enclosed in braces, and separated by commas.
i1 : L = {a,1,b,2}

o1 = {a, 1, b, 2}

o1 : List
The length of a list has two notations, the version with the # is faster when writing programs.
i2 : #L, length L

o2 = (4, 4)

o2 : Sequence
The first entry of the list has index 0. Indexing is performed using #.
i3 : L#2

o3 = b

o3 : Symbol

Lists in Macaulay2 are immutable. See MutableList for making and using lists that you may modify.

To convert lists to and from other types of BasicList, in addition to toList, one may use new.

i4 : new Array from {a,b,c}

o4 = [a, b, c]

o4 : Array
i5 : new List from [a,b,c]

o5 = {a, b, c}

o5 : List

For an overview of lists and sequences, see lists and sequences.

Types of list :

Functions and methods returning a list :

Methods that use a list :

Fixed objects of class List :

For the programmer

The object List is a type, with ancestor classes VisibleList < BasicList < Thing.