Sequences

A possibly-empty, immutable sequence of values. The type `Sequential<Element>` may be abbreviated `[Element*]` or `Element[]`.

`Sequential` has two enumerated subtypes:

- `Empty`, abbreviated `[]`, represents an empty sequence, and
- `Sequence``<Element>`, abbreviated `[Element+]` represents a non-empty sequence, and has the very important subclass `Tuple`.

See also `Tuple`

no type hierarchy

- `Sequential`
  - `List`
    - `Collection`
      - `Iterable`
        - `Category`
    - `Correspondence`
    - `Ranged`
      - `Iterable`
        - `Category`
  - `Ranged`
    - `Iterable`
      - `Category`

- `Sequential` of
  - `Empty`
    - `empty`
  - `Sequence`
    - `ArraySequence`
    - `Range`
    - `Singleton`
    - `Tuple`

Attributes
`exceptLast` | Source Code `shared formal Element[] exceptLast` This sequence, without the last element. Since 1.3.3 Refines `Iterable.exceptLast`
`keys` | Source Code `shared actual default Integer[] keys` A sequence containing all indexes of this sequence, that is, every index in the range `0:sequence.size`. Refines `List.keys` ultimately refines `Correspondence.keys`
`rest` | Source Code `shared formal Element[] rest` The rest of the sequence, without the first element. Refines `List.rest` ultimately refines `Iterable.rest`
`reversed` | Source Code `shared formal Element[] reversed` A sequence containing the elements of this sequence in reverse order to the order in which they occur in this sequence, or the empty sequence if this sequence is the empty sequence. Refines `List.reversed`
`size` | Source Code `shared formal Integer size` The strictly-positive length of this sequence, that is, the number of elements in this sequence. Refines `List.size` ultimately refines `Iterable.size`
`string` | Source Code `shared actual default String string` A string of form `"[ x, y, z ]"` where `x`, `y`, and `z` are the `string` representations of the elements of this collection, as produced by the iterator of the collection, or the string `"{}"` if this collection is empty. If the collection iterator produces the value `null`, the string representation contains the string `"null"`. Refines `Collection.string` ultimately refines `Object.string`

Inherited Attributes
Attributes inherited from: `Object` `hash`, `string`
Attributes inherited from: `Collection<Element>` `empty`, `permutations`, `string`
Attributes inherited from: `Correspondence<Key,Item>` `keys`
Attributes inherited from: `Iterable<Element,Absent>` `coalesced`, `cycled`, `distinct`, `empty`, `exceptLast`, `first`, `indexed`, `last`, `paired`, `rest`, `size`, `string`
Attributes inherited from: `List<Element>` `first`, `hash`, `keys`, `last`, `lastIndex`, `rest`, `reversed`, `size`

Methods
`append` | Source Code `shared formal <Element|Other>[] append<Other>(Other[] elements)` Return a sequence containing the elements of this sequence, in the order in which they occur in this sequence, followed by the given `elements`, in the order in which they occur in the given sequence. See also `prepend()`, `withTrailing()`, `concatenate()`, `Iterable.chain()` Since 1.1.0
`clone` | Source Code `shared actual default Element[] clone()` This sequence. Refines `List.clone` ultimately refines `Collection.clone`
`initial` | Source Code `shared actual default Element[] initial(Integer length)` Select the first elements of this sequence, returning a sequence no longer than the given length. If this sequence is shorter than the given length, return this sequence. Otherwise return a sequence of the given length. If `length<=0` return an `Empty` sequence. Refines `List.initial`
`prepend` | Source Code `shared formal <Element|Other>[] prepend<Other>(Other[] elements)` Return a sequence containing the given `elements`, in the order in which they occur in the given sequence, followed by the elements of this sequence, in the order in which they occur in this sequence. See also `append()`, `withLeading()`, `concatenate()` Since 1.1.0
`repeat` | Source Code `shared formal Element[] repeat(Integer times)` Produces a sequence formed by repeating the elements of this sequence the given number of times, or the empty sequence if `times<=0` or if this sequence is the empty sequence. Refines `List.repeat` ultimately refines `Iterable.repeat`
`sequence` | Source Code `shared actual default [Element+]|[] sequence()` This sequence. Refines `Iterable.sequence`
`slice` | Source Code `shared actual default Element[][2] slice(Integer index)` Return two sequences, the first containing the elements that occur before the given `index`, the second with the elements that occur after the given `index`. If the given `index` is outside the range of indices of this list, one of the returned sequences will be empty. Refines `List.slice`
`sublist` | Source Code `shared formal Element[] sublist(Integer from, Integer to)` A subsequence of this sequence, starting at the element with index `from`, ending at the element with the index `to`. Since 1.3.3 Refines `List.sublist`
`sublistFrom` | Source Code `shared formal Element[] sublistFrom(Integer from)` A subsequence of this sequence, starting at the element with the given index. Since 1.3.3 Refines `List.sublistFrom`
`sublistTo` | Source Code `shared formal Element[] sublistTo(Integer to)` A subsequence of this sequence, ending at the element with the given index. Since 1.3.3 Refines `List.sublistTo`
`terminal` | Source Code `shared actual default Element[] terminal(Integer length)` Select the last elements of the sequence, returning a sequence no longer than the given length. If this sequence is shorter than the given length, return this sequence. Otherwise return a sequence of the given length. Refines `List.terminal`
`trim` | Source Code `shared actual default Element[] trim(Boolean trimming(Element&Object element))` Trim the elements satisfying the given predicate function from the start and end of this sequence, returning a sequence no longer than this sequence. Parameters: `trimming` The predicate function that determines if an element at the start or end of this sequence should be trimmed Refines `List.trim`
`trimLeading` | Source Code `shared actual default Element[] trimLeading(Boolean trimming(Element&Object element))` Trim the elements satisfying the given predicate function from the start of this sequence, returning a sequence no longer than this sequence. Parameters: `trimming` The predicate function that determines if an element at the start of this sequence should be trimmed Refines `List.trimLeading`
`trimTrailing` | Source Code `shared actual default Element[] trimTrailing(Boolean trimming(Element&Object element))` Trim the elements satisfying the given predicate function from the end of this sequence, returning a sequence no longer than this sequence. Parameters: `trimming` The predicate function that determines if an element at the end of this sequence should be trimmed Refines `List.trimTrailing`
`tuple` | Source Code `shared formal Element[] tuple()` A `Tuple` with the same elements as this sequence. This operation makes it possible to narrow this sequence to a given static length, for example:
    assert (is String[3] bits
               = string.split('/'.equals)
                       .sequence()
                       .tuple);
    value [prefix, middle, postfix] = bits;
Since 1.3.3
`withLeading` | Source Code `shared formal [Other, Element*] withLeading<Other>(Other element)` Returns a new sequence that starts with the specified `element`, followed by the elements of this sequence, in the order they occur in this sequence. Parameters: `element` The first element of the resulting sequence. See also `prepend()`, `withTrailing()`, `Iterable.follow()` Since 1.1.0
`withTrailing` | Source Code `shared formal [Element|Other+] withTrailing<Other>(Other element)` Returns a new sequence that starts with the elements of this sequence, in the order they occur in this sequence, and ends with the specified `element`. Parameters: `element` The last element of the resulting sequence. See also `append()`, `withLeading()` Since 1.1.0

Inherited Methods
Methods inherited from: `Object` `equals()`
Methods inherited from: `Category<Element>` `contains()`, `containsAny()`, `containsEvery()`
Methods inherited from: `Collection<Element>` `clone()`, `combinations()`, `contains()`
Methods inherited from: `Correspondence<Key,Item>` `defines()`, `definesAny()`, `definesEvery()`, `get()`, `getAll()`
Methods inherited from: `Iterable<Element,Absent>` `any()`, `by()`, `chain()`, `collect()`, `contains()`, `count()`, `defaultNullElements()`, `each()`, `every()`, `filter()`, `find()`, `findLast()`, `flatMap()`, `fold()`, `follow()`, `frequencies()`, `getFromFirst()`, `group()`, `indexes()`, `interpose()`, `iterator()`, `locate()`, `locateLast()`, `locations()`, `longerThan()`, `map()`, `max()`, `narrow()`, `partition()`, `product()`, `reduce()`, `repeat()`, `scan()`, `select()`, `sequence()`, `shorterThan()`, `skip()`, `skipWhile()`, `sort()`, `spread()`, `summarize()`, `tabulate()`, `take()`, `takeWhile()`
Methods inherited from: `List<Element>` `clone()`, `collect()`, `contains()`, `defines()`, `endsWith()`, `equals()`, `find()`, `findLast()`, `firstIndexWhere()`, `get()`, `getFromFirst()`, `getFromLast()`, `indexesWhere()`, `initial()`, `iterator()`, `lastIndexWhere()`, `longerThan()`, `mapElements()`, `measure()`, `patch()`, `repeat()`, `shorterThan()`, `slice()`, `span()`, `spanFrom()`, `spanTo()`, `startsWith()`, `sublist()`, `sublistFrom()`, `sublistTo()`, `terminal()`, `trim()`, `trimLeading()`, `trimTrailing()`
Methods inherited from: `Ranged<Index,Element,Subrange>` `measure()`, `span()`, `spanFrom()`, `spanTo()`