27.5 Length

Length( list )

Length returns the length of the list list. The length is defined as 0 for the empty list, and as the largest positive integer index such that list[index] has an assigned value for nonempty lists. Note that the length of a list may change if new elements are added to it or assigned to previously unassigned positions.

    gap> Length( [] );
    0
    gap> Length( [ 2, 3, 5, 7, 11, 13, 17, 19 ] );
    8
    gap> Length( [ 1, 2,,, 5 ] );
    5 

For lists that contain no holes Length, Number (see Number), and Size (see Size) return the same value. For lists with holes Length returns the largest index of a bound entry, Number returns the number of bound entries, and Size signals an error.

Previous Up Top Next
Index

GAP 3.4.4
April 1997