Satisfied Interfaces: Category, Cloneable<List<Element>>, Collection<Element>, Correspondence<Integer,Element>, Iterable<Element,Null>, Ranged<Integer,List<Element>>
Direct Known Satisfying Classes: Array<Element>, LazyList<Element>, String
Direct Known Satisfying Interfaces: Sequential<Element>
All Known Subtypes Hierarchy

- List
  - Array
  - LazyList
  - Sequential
    - Empty
      - empty
    - Sequence
      - ArraySequence
      - Range
      - Singleton
      - Tuple
  - String

Represents a collection in which every element has a unique non-negative integer index.

A `List` is a `Collection` of its elements, and a `Correspondence` from indices to elements.

Direct access to a list element by index produces a value of optional type. The following idiom may be used instead of upfront bounds-checking, as long as the list element type is a non-`null` type:

    value char = "hello world"[index];
    if (exists char) { /*do something*/ }
    else { /*out of bounds*/ }

To iterate the indexes of a `List`, use the following idiom:

    for (i->char in "hello world".indexed) { ... }

See also: Sequence, Empty, Array

Attributes
first | Source Code shared actual default Element? first Returns the first element of this `List`, if any. Refined declaration: first
hash | Source Code shared actual default Integer hash The hash value of the value, which allows the value to be an element of a hash-based set or key of a hash-based map. Implementations must respect the constraint that if `x==y` then `x.hash==y.hash`. Refined declaration: hash
last | Source Code shared actual default Element? last Returns the last element of this `List`, if any. Refined declaration: last
lastIndex | Source Code shared formal Integer? lastIndex The index of the last element of the list, or null if the list is empty. See also: List.size
rest | Source Code shared formal List<Element> rest The rest of the list, without the first element. Refined declaration: rest
reversed | Source Code shared formal List<Element> reversed Reverse this list, returning a new list.
size | Source Code shared actual default Integer size The number of elements in this sequence, always `sequence.lastIndex+1`. See also: List.lastIndex Refined declaration: size

Inherited Attributes
Attributes inherited from: Object string
Attributes inherited from: Cloneable<Clone> clone
Attributes inherited from: Collection<Element> string
Attributes inherited from: Correspondence<Key,Item> keys
Attributes inherited from: Iterable<Element,Absent> coalesced, cycled, empty, first, indexed, last, rest, sequence, size, string

Methods
contains | Source Code shared actual default Boolean contains(Object element) Determines if this list contains the given value. Equivalent to `occurs()`. See also: occurs Refined declaration: contains
defines | Source Code shared actual default Boolean defines(Integer index) Determines if the given index refers to an element
    of this sequence, that is, if
    `index<=sequence.lastIndex`.
Refined declaration: defines
endsWith | Source Code shared default Boolean endsWith(List<Anything> sublist) Determine if the given list occurs at the end of this list.
equals | Source Code shared actual default Boolean equals(Object that) Two `List`s are considered equal iff they have the same `size` and entry sets. The entry set of a list `l` is the set of elements of `l.indexed`. This definition is equivalent to the more intuitive notion that two lists are equal iff they have the same `size` and for every index either: the lists both have the element `null`, or the lists both have a non-null element, and the two elements are equal. Refined declaration: equals
findLast | Source Code shared actual default Element? findLast(Boolean selecting(Element elem)) The last element which satisfies the given predicate, if any, or `null` otherwise. Refined declaration: findLast
firstInclusion | Source Code shared default Integer? firstInclusion(List<Anything> sublist) The first index in this list at which the given list occurs.
firstOccurrence | Source Code shared default Integer? firstOccurrence(Anything element) The first index in this list at which the given element occurs.
get | Source Code shared formal Element? get(Integer index) Returns the element of this sequence with the given
    index, or `null` if the given index is past the end
    of the sequence, that is, if
    `index>sequence.lastIndex`. The first element of
    the sequence has index `0`.
Refined declaration: get
includes | Source Code shared default Boolean includes(List<Anything> sublist) Determine if the given list occurs at some index in this list.
includesAt | Source Code shared default Boolean includesAt(Integer index, List<Anything> sublist) Determine if the given list occurs at the given index of this list. Parameters: index The index at which this list might occur
inclusions | Source Code shared default {Integer*} inclusions(List<Anything> sublist) The indexes in this list at which the given list occurs.
indexes | Source Code shared default {Integer*} indexes(Boolean selecting(Element element)) The indexes in this list for which the element satisfies the given predicate. Parameters: selecting The predicate the indexed elements must satisfy
initial | Source Code shared default List<Element> initial(Integer length) Select the first elements of this list, returning a list no longer than the given length. If this list is shorter than the given length, return this list. Otherwise return a list of the given length. See also: List.terminal
iterator | Source Code shared actual default Iterator<Element> iterator() An iterator for the elements belonging to this container. Refined declaration: iterator
lastInclusion | Source Code shared default Integer? lastInclusion(List<Anything> sublist) The last index in this list at which the given list occurs.
lastOccurrence | Source Code shared default Integer? lastOccurrence(Anything element) The last index in this list at which the given element occurs.
longerThan | Source Code shared actual default Boolean longerThan(Integer length) Determines if this iterable object has more elements than the given length. This is an efficient operation for iterable objects with many elements. Refined declaration: longerThan
occurrences | Source Code shared default {Integer*} occurrences(Anything element) The indexes in this list at which the given element occurs.
occurs | Source Code shared default Boolean occurs(Anything element) Determines if the given value occurs as an element in this list.
occursAt | Source Code shared default Boolean occursAt(Integer index, Anything element) Determines if the given value occurs at the given index in this list.
shorterThan | Source Code shared actual default Boolean shorterThan(Integer length) Determines if this iterable object has fewer elements than the given length. This is an efficient operation for iterable objects with many elements. Refined declaration: shorterThan
startsWith | Source Code shared default Boolean startsWith(List<Anything> sublist) Determine if the given list occurs at the start of this list.
terminal | Source Code shared default List<Element> terminal(Integer length) Select the last elements of the list, returning a list no longer than the given length. If this list is shorter than the given length, return this list. Otherwise return a list of the given length. See also: List.initial
trim | Source Code shared default List<Element> trim(Boolean trimming(Element elem)) Trim the elements satisfying the given predicate function from the start and end of this list, returning a list no longer than this list.
trimLeading | Source Code shared default List<Element> trimLeading(Boolean trimming(Element elem)) Trim the elements satisfying the given predicate function from the start of this list, returning a list no longer than this list.
trimTrailing | Source Code shared default List<Element> trimTrailing(Boolean trimming(Element elem)) Trim the elements satisfying the given predicate function from the end of this list, returning a list no longer than this list.
withLeading | Source Code shared default [<Element|Other>+] withLeading<Other>(Other element) Returns a new `List` that starts with the specified element, followed by the elements of this `List`. Parameters: element The first element of the resulting sequence. See also: following
withTrailing | Source Code shared default [<Element|Other>+] withTrailing<Other>(Other element) Returns a new `List` that contains the specified element appended to the end of the elements of this `List`. Parameters: element The last element of the resulting sequence.

Inherited Methods
Methods inherited from: Category contains, containsAny, containsEvery
Methods inherited from: Correspondence<Key,Item> defines, definesAny, definesEvery, get, items
Methods inherited from: Iterable<Element,Absent> any, by, chain, collect, count, cycle, defaultNullElements, every, filter, find, findLast, fold, following, iterator, longerThan, map, repeat, select, shorterThan, skipping, skippingWhile, sort, taking, takingWhile
Methods inherited from: Ranged<Index,Span> segment, span, spanFrom, spanTo