Type Hierarchy:

- Anything
  - Object
    - Tuple<out Element,out First,out Rest = []>

Satisfied Interfaces: Category, Cloneable<List<Element>>, Collection<Element>, Correspondence<Integer,Element>, Iterable<Element,Nothing>, List<Element>, Ranged<Integer,List<Element>>, Sequence<Element>, Sequential<Element>

A tuple is a typed linked list. Each instance of `Tuple` represents the value and type of a single link. The attributes `first` and `rest` allow us to retrieve a value form the list without losing its static type information.

    value point = Tuple(0.0, Tuple(0.0, Tuple("origin")));
    Float x = point.first;
    Float y = point.rest.first;
    String label = point.rest.rest.first;

Usually, we abbreviate code involving tuples.

    [Float,Float,String] point = [0.0, 0.0, "origin"];
    Float x = point[0];
    Float y = point[1];
    String label = point[2];

A list of types enclosed in brackets is an abbreviated tuple type. An instance of `Tuple` may be constructed by surrounding a value list in brackets:

    [String,String] words = ["hello", "world"];

The index operator with a literal integer argument is a shortcut for a chain of evaluations of `rest` and `first`. For example, `point[1]` means `point.rest.first`.

A terminated tuple type is a tuple where the type of the last link in the chain is `Empty`. An unterminated tuple type is a tuple where the type of the last link in the chain is `Sequence` or `Sequential`. Thus, a terminated tuple type has a length that is known statically. For an unterminated tuple type only a lower bound on its length is known statically.

Here, `point` is an unterminated tuple:

    String[] labels = ... ;
    [Float,Float,String*] point = [0.0, 0.0, *labels];
    Float x = point[0];
    Float y = point[1];
    String? firstLabel = point[2];
    String[] allLabels = point[2...];

By: Gavin

Initializer
Tuple(First first, Rest rest) Parameters: first The first element of this tuple. rest A tuple with the elements of this tuple, except for the first element.

Attributes
clone | shared actual Tuple<Element,First,Rest> clone Obtain a clone of this object. For a mutable object, this should return a copy of the object. For an immutable object, it is acceptable to return the object itself. Refined declaration: clone
first | Source Code shared actual First first The first element of this tuple. Refined declaration: first
last | Source Code shared actual Element last The last element returned by the iterator, if any, of `null` if the iterable object is empty. Iterable objects are potentially infinite, so calling this might never return; also, this implementation will iterate through all the elements, which might be very time-consuming. Refined declaration: last
lastIndex | Source Code shared actual Integer lastIndex The index of the last element of the list, or null if the list is empty. Refined declaration: lastIndex
rest | Source Code shared actual Rest rest A tuple with the elements of this tuple, except for the first element. Refined declaration: rest
reversed | shared actual [Element+] reversed Reverse this list, returning a new list. Refined declaration: reversed
size | shared actual Integer size The number of elements returned by the iterator of this iterable object, if the iterator terminates. In the case of an iterable whose elements are not countable, this operation never terminates. Refined declaration: size

Inherited Attributes
Attributes inherited from: Object hash, 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
Attributes inherited from: List<Element> hash, lastIndex, reversed
Attributes inherited from: [Element+] string
Attributes inherited from: Element[] string

Methods
contains | Source Code shared actual Boolean contains(Object element) Determines if the given value belongs to this `Category`, that is, if it is an element of this `Category`. For most `Category`s, if `x==y`, then `category.contains(x)` evaluates to the same value as `category.contains(y)`. However, it is possible to form a `Category` consistent with some other equivalence relation, for example `===`. Therefore implementations of `contains()` which do not satisfy this relationship are tolerated. Refined declaration: contains
get | Source Code shared actual Element? get(Integer index) Returns the value defined for the given key, or `null` if there is no value defined for the given key. Refined declaration: get
iterator | Source Code shared actual Iterator<Element> iterator() An iterator for the elements belonging to this container. Refined declaration: iterator
segment | Source Code shared actual Element[] segment(Integer from, Integer length) Obtain a segment containing the mapped values starting from the given index, with the given length. Refined declaration: segment
span | Source Code shared actual Element[] span(Integer from, Integer end) Obtain a span containing the mapped values between the two given indices. Refined declaration: span
spanFrom | shared actual Element[] spanFrom(Integer from) Obtain a span containing the mapped values between the starting index and the end of the receiver. Refined declaration: spanFrom
spanTo | shared actual Element[] spanTo(Integer to) Obtain a span containing the mapped values between the start of the receiver and the end index. Refined declaration: spanTo
withLeading | Source Code shared actual Tuple<Element|Other,Other,Tuple<Element,First,Rest>> withLeading<Other>(Other element) Returns a new tuple that starts with the specified element, followed by the elements of this tuple. Parameters: element The first element of the resulting tuple. Refined declaration: withLeading

Inherited Methods
Methods inherited from: Object equals
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: List<Element> endsWith, equals, firstInclusion, firstOccurrence, includes, includesAt, inclusions, indexes, initial, lastInclusion, lastOccurrence, occurrences, occurs, occursAt, startsWith, terminal, trim, trimLeading, trimTrailing, withLeading, withTrailing
Methods inherited from: Ranged<Index,Span> segment, span, spanFrom, spanTo