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 from 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

no subtypes hierarchy

 Initializer Tuple(First first, Rest rest)Parameters: firstThe first element of this tuple. (The head of the linked list.) restA tuple with the elements of this tuple, except for the first element. (The tail of the linked list.)
 Attributes first Source Codeshared actual First firstThe first element of this tuple. (The head of the linked list.) Refines Sequence.first ultimately refines Iterable.first last Source Codeshared actual Element lastThe last element of this tuple. Refines Sequence.last ultimately refines Iterable.last lastIndex Source Codeshared actual Integer lastIndexThe index of the last element of the list, or null if the list is empty. Refines Sequence.lastIndex ultimately refines List.lastIndex rest Source Codeshared actual Rest restA tuple with the elements of this tuple, except for the first element. (The tail of the linked list.) Refines Sequence.rest ultimately refines Iterable.rest size Source Codeshared actual Integer sizeThe number of elements returned by the Iterable.iterator() of this stream, if the iterator terminates. In the case of an infinite stream, this operation never terminates. Refines Sequence.size ultimately refines Iterable.size
 Inherited Attributes Attributes inherited from: Object Attributes inherited from: CollectionCollection.string Attributes inherited from: CorrespondenceCorrespondence.keys Attributes inherited from: Iterable Attributes inherited from: List Attributes inherited from: Sequence.string Attributes inherited from: Sequential.string
 Methods append Source Codeshared actual append( elements)Return a tuple containing the elements of this tuple, followed by the given elements. Parameters: elementsThe list of elements to be appended. Refines Sequence.append ultimately refines Sequential.append clone Source Codeshared actual Tuple clone()This tuple. Refines Sequence.clone ultimately refines Collection.clone contains Source Codeshared actual Boolean contains(Object element)Determine if the given value is an element of this tuple. Refines Sequence.contains ultimately refines Category.contains getFromFirst Source Codeshared actual getFromFirst(Integer index)The indexth element returned by an iterator of this stream, or null if there are fewer than index+1 elements in the stream. For a stream with an unstable iteration order, a different value might be produced each time getFromFirst(index) is called for a given integer index. Refines Iterable.getFromFirst iterator Source Codeshared actual Iterator iterator()An iterator for the elements belonging to this stream. Refines Iterable.iterator measure Source Codeshared actual measure(Integer from, Integer length)Obtain a measure containing the mapped values starting from the given starting index, with the given length. If length<=0, the resulting measure is empty. The measure should contain the given number of elements of this stream, starting from the element at the given starting index, in the same order as they are produced by the Iterable.iterator() of the stream. In the case where the iterator would be exhausted before length elements are produced, the resulting measure contains only those elements which were produced before the iterator was exhausted, and the length of the measure is less then the given length. When the given index does not belong to this ranged object, the behavior is implementation dependent. Refines Sequence.measure ultimately refines Ranged.measure span Source Codeshared actual span(Integer from, Integer end)Obtain a span containing the elements between the two given indices. The span should contain elements of this stream, starting from the element at the given starting index, and ending with the element at the given ending index, in the same order as they are produced by the Iterable.iterator() of the stream, except when the ending index occurs earlier than the starting index, in which case they occur in the opposite order. When one or both of the given indices does not belong to this ranged stream, the behavior is implementation dependent. Refines Sequence.span ultimately refines Ranged.span spanFrom Source Codeshared actual spanFrom(Integer from)Obtain a span containing the elements between the given starting index and the last index of this ranged object. The span should contain elements of this stream, starting from the element at the given starting index, in the same order as they are produced by the Iterable.iterator() of the stream. When the given index does not belong to this ranged stream, the behavior is implementation dependent. Refines Sequence.spanFrom ultimately refines Ranged.spanFrom spanTo Source Codeshared actual spanTo(Integer to)Obtain a span containing the elements between the first index of this ranged stream and given end index. The span should contain elements of this stream, up to the element at the given ending index, in the same order as they are produced by the Iterable.iterator() of the stream. When the given index does not belong to this ranged stream, the behavior is implementation dependent. Refines Sequence.spanTo ultimately refines Ranged.spanTo withLeading Source Codeshared actual Tuple> withLeading(Other element)Return a new tuple that starts with the specified element, followed by the elements of this tuple. Parameters: elementThe first element of the resulting tuple. Refines Sequence.withLeading ultimately refines Sequential.withLeading withTrailing Source Codeshared actual withTrailing(Other element)Return a new tuple containing the elements of this tuple, followed by the given element. Parameters: elementThe last element of the resulting tuple. Refines Sequence.withTrailing ultimately refines Sequential.withTrailing
 Inherited Methods Methods inherited from: ObjectObject.equals() Methods inherited from: Category Methods inherited from: CollectionCollection.clone() Methods inherited from: Correspondence Methods inherited from: Iterable Methods inherited from: List Methods inherited from: Ranged Methods inherited from: