TupleOps

io.github.cakelier.tuples.space.TupleOps$
See theTupleOps companion trait
object TupleOps

Companion object to the TupleOps type-class, containing the type-class interface and the implementation for the JsonTuple type.

Attributes

Companion
trait
Graph
Supertypes
class Object
trait Matchable
class Any
Self type
TupleOps.type

Members list

Givens

Givens

given given_TupleOps_T_JsonElement_JsonTuple[T <: JsonTuple]: given_TupleOps_T_JsonElement_JsonTuple[T]

The implementation of the TupleOps type-class for the JsonTuple type and its element type, JsonElement.

The implementation of the TupleOps type-class for the JsonTuple type and its element type, JsonElement.

Attributes

Extensions

Extensions

extension [T <: G, E, G](t1: T)(t1: T)(using TupleOps[T, E, G])
def foldLeft[A](z: A)(a: (A, E) => A): A

Returns an element which is the result of accumulating all elements of this 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 this tuple. If this tuple is empty the starting element will be returned.

Returns an element which is the result of accumulating all elements of this 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 this tuple. If this 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

z

the starting element of the folding operation

Attributes

Returns

all elements in this tuple folded into one, starting from the given element and combining them once at a time using the given accumulation function

def foldRight[A](z: A)(a: (E, A) => A): A

Returns an element which is the result of accumulating all elements of this 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 this tuple. If this tuple is empty the starting element will be returned.

Returns an element which is the result of accumulating all elements of this 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 this tuple. If this 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

z

the starting element of the folding operation

Attributes

Returns

all elements in this tuple folded into one, starting from the given element and combining them once at a time using the given accumulation function

extension [T <: G, E, G](t1: T)(t1: T)(using TupleOps[T, E, G])
infix def :#(v: E): G

Appends an element to the end of this 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 this 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

v

the element to be appended

Attributes

Returns

a new tuple with the given element appended to it

def :##(t: G): G

Concatenates the given tuple after this one, 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 given tuple after this one, 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

t

the tuple to be concatenated

Attributes

Returns

a new tuple with the given one added to the end of this one

def arity: Int

Returns the arity, i.e. the number of elements of this tuple. An empty tuple returns an arity of 0.

Returns the arity, i.e. the number of elements of this tuple. An empty tuple returns an arity of 0.

Attributes

def drop(n: Int): G

Drops the first elements of this tuple in a given number, returning a tuple with the same elements as this, 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 this tuple is returned unchanged.

Drops the first elements of this tuple in a given number, returning a tuple with the same elements as this, 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 this tuple is returned unchanged.

Value parameters

n

the number of elements to be dropped from the beginning

Attributes

Returns

this tuple with the first elements at the beginning dropped, if possible, the unchanged tuple otherwise

def elem(n: Int): Option[E]

Returns the element at the n-th position in this 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 this 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

Attributes

Returns

a Some containing the element at the n-th position in this tuple if it exists, a None otherwise

def filter(p: E => Boolean): G

Returns a copy of this tuple where only the elements passing the given predicate used as filter are kept. If all elements make the predicate return true, this tuple is returned. If no element make the predicate return true, an empty tuple is returned.

Returns a copy of this tuple where only the elements passing the given predicate used as filter are kept. If all elements make the predicate return true, this 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

Attributes

Returns

a tuple with only the elements from this one passing the predicate used as filter

def flatMap(f: E => G): G

Returns a tuple where the given function has been applied for every element in this 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 this 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 of this tuple

Attributes

Returns

a tuple where each element in it has been transformed according to the given function

def foreach(f: E => Unit): Unit

Executes the given action for each element of this tuple, allowing for side-effect-ful operations on the tuple. If this tuple is an empty tuple, the action is performed zero times.

Executes the given action for each element of this tuple, allowing for side-effect-ful operations on the tuple. If this tuple is an empty tuple, the action is performed zero times.

Value parameters

f

the action to be performed on each element of this tuple

Attributes

def head: Option[E]

Returns the head of the given tuple, so its first element. If the tuple is empty, a None is returned.

Returns the head of the given tuple, so its first element. If the tuple is empty, a None is returned.

Attributes

def init: G

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.

Attributes

def last: Option[E]

Returns the last element of the given tuple, if it exists. If the tuple is empty a None is returned.

Returns the last element of the given tuple, if it exists. If the tuple is empty a None is returned.

Attributes

def map(f: E => E): G

Returns a tuple where the given function has been applied for every element in this 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 this 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 of this tuple

Attributes

Returns

a tuple where each element in it has been transformed according to the given function

def split(n: Int): G

Splits this tuple into two at the given index, returning a tuple made of two tuples, which concatenated make this 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 this tuple. If the given index is negative, this tuple is returned. If an empty tuple is given to split, a tuple made of two empty tuples is then returned.

Splits this tuple into two at the given index, returning a tuple made of two tuples, which concatenated make this 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 this tuple. If the given index is negative, this 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

Attributes

Returns

a tuple made of two tuples, which concatenated will yield this tuple

def tail: G

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.

Attributes

def take(n: Int): G

Returns this tuple with only the first elements kept in a number which is given, 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, this tuple is returned.

Returns this tuple with only the first elements kept in a number which is given, 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, this tuple is returned.

Value parameters

n

the number of elements to take

Attributes

Returns

this tuple with only the first given number of elements kept

def toSeq: Seq[E]

Returns this tuple as a Seq, keeping the elements in the same order as in the tuple. If this tuple is an empty tuple, an empty Seq is returned.

Returns this tuple as a Seq, keeping the elements in the same order as in the tuple. If this tuple is an empty tuple, an empty Seq is returned.

Attributes

def zip(t: G): G

Returns a tuple which elements are tuples made by an element of this tuple and an element of the given 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 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 this tuple and an element of the given 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 tuples is an empty tuple, then the returned tuple is an empty tuple.

Value parameters

t

the other tuple to be zipped

Attributes

Returns

a tuple which elements are tuples which couple the corresponding elements of this tuple and the given tuple