A tuple is a typed linked list. Each instance of
Tuple represents the value and type of a single link.
rest allow us to retrieve
a value form the list without losing its static type
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; Float y = point; String label = point;
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
first. For example,
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
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.
point is an unterminated tuple:
String labels = ... ; [Float,Float,String*] point = [0.0, 0.0, *labels]; Float x = point; Float y = point; String? firstLabel = point; String allLabels = point[2...];
|Tuple(First first, Rest rest)|
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
shared actual First first
The first element of this tuple.
Refined declaration: first
shared actual Element last
The last element returned by the iterator, if any,
Refined declaration: last
shared actual Integer lastIndex
The index of the last element of the list, or null if the list is empty.
Refined declaration: lastIndex
shared actual Rest rest
A tuple with the elements of this tuple, except for the first element.
Refined declaration: rest
shared actual reversed
Reverse this list, returning a new list.
Refined declaration: reversed
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
|Attributes inherited from: Object|
|Attributes inherited from: Cloneable<Clone>|
|Attributes inherited from: Collection<Element>|
|Attributes inherited from: Correspondence<Key,Item>|
|Attributes inherited from: Iterable<Element,Absent>|
|Attributes inherited from: List<Element>|
|Attributes inherited from:|
|Attributes inherited from:|
Determines if the given value belongs to this
Refined declaration: contains
shared actual get(Integer index)
Returns the value defined for the given key, or
Refined declaration: get
shared actual Iterator<Element> iterator()
An iterator for the elements belonging to this container.
Refined declaration: iterator
Obtain a segment containing the mapped values starting from the given index, with the given length.
Refined declaration: segment
Obtain a span containing the mapped values between the two given indices.
Refined declaration: span
shared actual spanFrom(Integer from)
Obtain a span containing the mapped values between the starting index and the end of the receiver.
Refined declaration: spanFrom
shared actual spanTo(Integer to)
Obtain a span containing the mapped values between the start of the receiver and the end index.
Refined declaration: spanTo
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.
Refined declaration: withLeading
|Methods inherited from: Object|
|Methods inherited from: Category|
|Methods inherited from: Correspondence<Key,Item>|
|Methods inherited from: Iterable<Element,Absent>|
|Methods inherited from: List<Element>|
|Methods inherited from: Ranged<Index,Span>|