A type-class representing the operations that must be supported by a tuple-like object.
Objects representing tuples, being so, must provide some operations that are expected to work on them. A tuple must allow to peek its internal structure in a predictable way, giving access to its number of elements, the elements at any given position, its head or its tail, to the initial part of it or the ending element. A tuple must also provide operations to update it, returning a new tuple, in a similar fashion to a sequence. So, elements can be appended, dropped, filtered, mapped, flat-mapped, taken, folded or an action can be performed for each one of them. At last, a tuple can be concatenated to another tuple, it can be converted to a Seq, existing a bijective relationship between them, split into two or zipped with another.
Type parameters
- E
-
the concrete type of an element in the tuple
- G
-
the abstract type of tuple to which the concrete type belongs
- T
-
the concrete type of tuple that must support these operations
Attributes
- Companion
- object
- Graph
-
- Supertypes
-
class Objecttrait Matchableclass Any
Members list
Value members
Abstract methods
Appends an element to the end of the tuple, making it grow one element from the end. If an empty tuple is used for appending an element, the resulting tuple has only one element which is also its head.
Appends an element to the end of the tuple, making it grow one element from the end. If an empty tuple is used for appending an element, the resulting tuple has only one element which is also its head.
Value parameters
- t
-
the tuple to which appending an element
- v
-
the element to be appended
Attributes
- Returns
-
a new tuple with the given element appended to it
Concatenates the second tuple after the first, with the resulting tuple having as arity the sum of both of them. If either of the tuples is an empty tuple, this operation returns the other, as concatenating an empty tuple has no effect.
Concatenates the second tuple after the first, with the resulting tuple having as arity the sum of both of them. If either of the tuples is an empty tuple, this operation returns the other, as concatenating an empty tuple has no effect.
Value parameters
- t1
-
the tuple to which concatenate the second
- t2
-
the tuple to be concatenated to the first
Attributes
- Returns
-
a new tuple with the second one added to the end of the first one
Returns the arity, i.e. the number of elements of the tuple. An empty tuple returns an arity of 0.
Returns the arity, i.e. the number of elements of the tuple. An empty tuple returns an arity of 0.
Value parameters
- t
-
the tuple for which calculating the arity
Attributes
- Returns
-
the arity of the tuple
Drops the first elements of the given tuple in a given number, returning a tuple with the same elements as the given one, except the ones at the beginning. If the given value exceeds the arity of the tuple or it is a negative number, no operation is performed and the given tuple is returned unchanged.
Drops the first elements of the given tuple in a given number, returning a tuple with the same elements as the given one, except the ones at the beginning. If the given value exceeds the arity of the tuple or it is a negative number, no operation is performed and the given tuple is returned unchanged.
Value parameters
- n
-
the number of elements to be dropped from the beginning
- t
-
the tuple from which dropping the first elements
Attributes
- Returns
-
the given tuple with the first elements at the beginning dropped, if possible, the unchanged tuple otherwise
Returns the element at the n-th position in the tuple, if one exists. If no element exists, either because the position exceeds the arity of the tuple or it is a negative number, a None is returned.
Returns the element at the n-th position in the tuple, if one exists. If no element exists, either because the position exceeds the arity of the tuple or it is a negative number, a None is returned.
Value parameters
- n
-
the position from which extracting an element
- t
-
the tuple from which extracting an element
Attributes
Returns a copy of the given tuple where only the elements passing the given predicate used as filter are kept. If all elements make the predicate return true
, the original tuple is returned. If no element make the predicate return true
, an empty tuple is returned.
Returns a copy of the given tuple where only the elements passing the given predicate used as filter are kept. If all elements make the predicate return true
, the original tuple is returned. If no element make the predicate return true
, an empty tuple is returned.
Value parameters
- p
-
the predicate to be used as filter
- t
-
the tuple on which applying the given filter
Attributes
- Returns
-
a tuple with only the elements of the given one passing the predicate used as filter
Returns a tuple where the given function has been applied for every element in the given tuple. This operation maps elements of the tuple into tuples, so a flattening operation, or concatenation, is then performed so as to obtain a tuple as a result. The flattening happens only on one level, so if a tuple containing a tuple is returned by the function, the inner tuple will be an element of the resulting tuple.
Returns a tuple where the given function has been applied for every element in the given tuple. This operation maps elements of the tuple into tuples, so a flattening operation, or concatenation, is then performed so as to obtain a tuple as a result. The flattening happens only on one level, so if a tuple containing a tuple is returned by the function, the inner tuple will be an element of the resulting tuple.
Value parameters
- f
-
the function to be applied on each element
- t
-
the tuple on which applying the given function on each element
Attributes
- Returns
-
a tuple where each element in it has been transformed according to the given function
Returns an element which is the result of accumulating all elements of the given tuple from left to right, using the given element as a starting point and the given function as the accumulator. Being so, the accumulator will specify how to combine the elements folded so far into a single value with a new element of the tuple. If the given tuple is empty the starting element will be returned.
Returns an element which is the result of accumulating all elements of the given tuple from left to right, using the given element as a starting point and the given function as the accumulator. Being so, the accumulator will specify how to combine the elements folded so far into a single value with a new element of the tuple. If the given tuple is empty the starting element will be returned.
Type parameters
- A
-
the type of the resulting element of this function
Value parameters
- a
-
the accumulation function
- t
-
the tuple on which applying the folding operation
- z
-
the starting element of the folding operation
Attributes
- Returns
-
all elements in the given tuple folded into one, starting from the given element and combining them once at a time using the given accumulation function
Returns an element which is the result of accumulating all elements of the given tuple from right to left, using the given element as a starting point and the given function as the accumulator. Being so, the accumulator will specify how to combine the elements folded so far into a single value with a new element of the tuple. If the given tuple is empty the starting element will be returned.
Returns an element which is the result of accumulating all elements of the given tuple from right to left, using the given element as a starting point and the given function as the accumulator. Being so, the accumulator will specify how to combine the elements folded so far into a single value with a new element of the tuple. If the given tuple is empty the starting element will be returned.
Type parameters
- A
-
the type of the resulting element of this function
Value parameters
- a
-
the accumulation function
- t
-
the tuple on which applying the folding operation
- z
-
the starting element of the folding operation
Attributes
- Returns
-
all elements in the given tuple folded into one, starting from the given element and combining them once at a time using the given accumulation function
Executes the given action for each element of the given tuple, allowing for side-effect-ful operations on the tuple. If the given tuple is an empty tuple, the action is performed zero times.
Executes the given action for each element of the given tuple, allowing for side-effect-ful operations on the tuple. If the given tuple is an empty tuple, the action is performed zero times.
Value parameters
- f
-
the action to be performed
- t
-
the tuple on which executing the action for each element
Attributes
Returns the head of the given tuple, so its first element. If the tuple is empty, a None is returned.
Returns the initial part of the given tuple, so all its elements except its last. If the tuple is empty or contains only one element, its tail is also empty, so an empty tuple is returned.
Returns the initial part of the given tuple, so all its elements except its last. If the tuple is empty or contains only one element, its tail is also empty, so an empty tuple is returned.
Value parameters
- t
-
the tuple from which getting its initial part
Attributes
- Returns
-
the initial part of the given tuple
Returns the last element of the given tuple, if it exists. If the tuple is empty a None is returned.
Returns a tuple where the given function has been applied for every element in the given tuple. This operation maps elements of the tuple into elements of the tuple, which means that if the function returns a tuple, this is not concatenated, but inserted into the result as any other element.
Returns a tuple where the given function has been applied for every element in the given tuple. This operation maps elements of the tuple into elements of the tuple, which means that if the function returns a tuple, this is not concatenated, but inserted into the result as any other element.
Value parameters
- f
-
the function to be applied on each element
- t
-
the tuple on which applying the given function on each element
Attributes
- Returns
-
a tuple where each element in it has been transformed according to the given function
Splits the given tuple into two at the given index, returning a tuple made of two tuples, which concatenated make the original tuple. The splitting is always made to include the element at the given index in the second tuple, so an index of 0
will always return a tuple made of an empty tuple followed by the original tuple. If the given index is negative, the original tuple is returned. If an empty tuple is given to split, a tuple made of two empty tuples is then returned.
Splits the given tuple into two at the given index, returning a tuple made of two tuples, which concatenated make the original tuple. The splitting is always made to include the element at the given index in the second tuple, so an index of 0
will always return a tuple made of an empty tuple followed by the original tuple. If the given index is negative, the original tuple is returned. If an empty tuple is given to split, a tuple made of two empty tuples is then returned.
Value parameters
- n
-
the index at which splitting the tuple
- t
-
the tuple to split
Attributes
- Returns
-
a tuple made of two tuples, which concatenated will yield the original tuple
Returns the tail of the given tuple, so all elements excluding its first one. If the tuple is empty, its tail is also empty, so an empty tuple is returned.
Returns the tail of the given tuple, so all elements excluding its first one. If the tuple is empty, its tail is also empty, so an empty tuple is returned.
Value parameters
- t
-
the tuple from which getting its tail
Attributes
- Returns
-
the tail of the given tuple
Returns the given tuple with only the first given number of elements kept, while the ones exceeding the count are dropped. If a value of 0
is supplied, an empty tuple is returned. If a negative value is supplied, the original tuple is returned.
Returns the given tuple with only the first given number of elements kept, while the ones exceeding the count are dropped. If a value of 0
is supplied, an empty tuple is returned. If a negative value is supplied, the original tuple is returned.
Value parameters
- n
-
the number of elements to take
- t
-
the tuple from which taking its first elements
Attributes
- Returns
-
the given tuple with only the first given number of elements kept
Returns a tuple which elements are tuples made by an element of the given first tuple and an element of the given second tuple. The elements are coupled one by one by their corresponding positions. This means that, if one tuple has an arity greater than the other, the exceeding elements are dropped and not coupled. This means also that if one of the two given tuples is an empty tuple, then the returned tuple is an empty tuple.
Returns a tuple which elements are tuples made by an element of the given first tuple and an element of the given second tuple. The elements are coupled one by one by their corresponding positions. This means that, if one tuple has an arity greater than the other, the exceeding elements are dropped and not coupled. This means also that if one of the two given tuples is an empty tuple, then the returned tuple is an empty tuple.
Value parameters
- t1
-
the first tuple to be zipped
- t2
-
the second tuple to be zipped
Attributes
- Returns
-
a tuple which elements are tuples which couple the corresponding elements of the two given tuples