A list can be written by writing down the elements in order between
square brackets [, ], and separating them with commas ,. An empty
list, i.e., a list with no elements, is written as [].
gap> [ 1, 2, 3 ]; [ 1, 2, 3 ] # a list with three elements gap> [ [], [ 1 ], [ 1, 2 ] ]; [ [ ], [ 1 ], [ 1, 2 ] ] # a list may contain other lists
Each list constructed this way is mutable (see Mutability and Copyability).
IsList( obj ) C
tests whether obj is a list.
gap> IsList( [ 1, 3, 5, 7 ] ); IsList( 1 ); true false
IsDenseList( obj ) C
A list is dense if it has no holes, i.e., contains an element at every position. It is absolutely legal to have lists with holes. They are created by leaving the entry between the commas empty. Holes at the end of a list are ignored. Lists with holes are sometimes convenient when the list represents a mapping from a finite, but not consecutive, subset of the positive integers.
gap> IsDenseList( [ 1, 2, 3 ] ); true gap> l := [ , 4, 9,, 25,, 49,,,, 121 ];; IsDenseList( l ); false gap> l[3]; 9 gap> l[4]; Error, List Element: <list>[4] must have a value
IsHomogeneousList( obj ) C
A homogeneous list is a dense list whose elements lie in the same family (see Families). The empty list is homogeneous but not a collection (see Collections), a nonempty homogeneous list is also a collection.
gap> IsHomogeneousList( [ 1, 2, 3 ] ); IsHomogeneousList( [] ); true true gap> IsHomogeneousList( [ 1, false, () ] ); false
IsTable( obj ) C
A table is a nonempty list of homogeneous lists which lie in the same family. Typical examples of tables are matrices (see Matrices).
gap> IsTable( [ [ 1, 2 ], [ 3, 4 ] ] ); # in fact a matrix true gap> IsTable( [ [ 1 ], [ 2, 3 ] ] ); # not rectangular but a table true gap> IsTable( [ [ 1, 2 ], [ () , (1,2) ] ] ); # not homogeneous false
IsConstantTimeAccessList( list ) C
This category indicates whether the access to each element of the list
list will take roughly the same time.
This is implied for example by IsList and IsInternalRep,
so all strings, Boolean lists, ranges, and internally represented plain
lists are in this category.
But also other enumerators (see Enumerators) can lie in this category if they guarantee constant time access to their elements.
GAP 4 manual