Divooka Reference

Value Tuple Routines

16 nodes

On this page 16

Compare

Function

Orders two tuples of the same type element by element: the first position where they differ decides, as in sorting by several columns.

Signature
Compare(left: TTuple, right: TTuple) -> Integer
int Compare(TTuple left, TTuple right)

Parameters

nametypedefaultdescription
leftTTuple—The first tuple.
rightTTuple—The second tuple.

Returns

resultInteger
Ships with
Divooka ExploreDivooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
Value Tuple Routines
Package
Standard Library

Compare Objects

Function

Orders two values when you only have them as plain objects, using the left value's own comparison; null sorts before everything else.

Signature
CompareObjects(left: Any, right: Any) -> Integer
int CompareObjects(object left, object right)

Parameters

nametypedefaultdescription
leftAny—The first value; it must be comparable (as tuples, numbers and text are), or System.ArgumentException is thrown. Null sorts first.
rightAny—The second value; it must be of a type the left value can compare against, or the left value's comparison throws (for a tuple, System.ArgumentException).

Returns

resultInteger
Ships with
Divooka ExploreDivooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
Value Tuple Routines
Package
Standard Library

Create

Function

Overload 1 of 9

Signature
Create() -> ValueTuple
ValueTuple Create()

Makes the empty tuple, which holds no elements; it is the tuple form of "nothing", and every empty tuple equals every other.

Returns

resultValueTuple

Overload 2 of 9

Signature
Create(item1: T1) -> (T1)
ValueTuple<T1> Create(T1 item1)

Makes a tuple holding one element.

Parameters

nametypedefaultdescription
item1T1—The element.

Returns

result(T1)

Overload 3 of 9

Signature
Create(item1: T1, item2: T2) -> (T1, T2)
(T1, T2) Create(T1 item1, T2 item2)

Makes a pair: a tuple holding two elements, which may be of different types, for passing two related values along one wire.

Parameters

nametypedefaultdescription
item1T1—The first element.
item2T2—The second element.

Returns

result(T1, T2)

Overload 4 of 9

Signature
Create(item1: T1, item2: T2, item3: T3) -> (T1, T2, T3)
(T1, T2, T3) Create(T1 item1, T2 item2, T3 item3)

Makes a tuple holding three elements, which may be of different types.

Parameters

nametypedefaultdescription
item1T1—The first element.
item2T2—The second element.
item3T3—The third element.

Returns

result(T1, T2, T3)

Overload 5 of 9

Signature
Create -> (T1, T2, T3, T4)
    item1: T1
    item2: T2
    item3: T3
    item4: T4
(T1, T2, T3, T4) Create(T1 item1, T2 item2, T3 item3, T4 item4)

Makes a tuple holding four elements, which may be of different types.

Parameters

nametypedefaultdescription
item1T1—The first element.
item2T2—The second element.
item3T3—The third element.
item4T4—The fourth element.

Returns

result(T1, T2, T3, T4)

Overload 6 of 9

Signature
Create -> (T1, T2, T3, T4, T5)
    item1: T1
    item2: T2
    item3: T3
    item4: T4
    item5: T5
(T1, T2, T3, T4, T5) Create(
    T1 item1,
    T2 item2,
    T3 item3,
    T4 item4,
    T5 item5)

Makes a tuple holding five elements, which may be of different types.

Parameters

nametypedefaultdescription
item1T1—The first element.
item2T2—The second element.
item3T3—The third element.
item4T4—The fourth element.
item5T5—The fifth element.

Returns

result(T1, T2, T3, T4, T5)

Overload 7 of 9

Signature
Create -> (T1, T2, T3, T4, T5, T6)
    item1: T1
    item2: T2
    item3: T3
    item4: T4
    item5: T5
    item6: T6
(T1, T2, T3, T4, T5, T6) Create(
    T1 item1,
    T2 item2,
    T3 item3,
    T4 item4,
    T5 item5,
    T6 item6)

Makes a tuple holding six elements, which may be of different types.

Parameters

nametypedefaultdescription
item1T1—The first element.
item2T2—The second element.
item3T3—The third element.
item4T4—The fourth element.
item5T5—The fifth element.
item6T6—The sixth element.

Returns

result(T1, T2, T3, T4, T5, T6)

Overload 8 of 9

Signature
Create -> (T1, T2, T3, T4, T5, T6, T7)
    item1: T1
    item2: T2
    item3: T3
    item4: T4
    item5: T5
    item6: T6
    item7: T7
(T1, T2, T3, T4, T5, T6, T7) Create(
    T1 item1,
    T2 item2,
    T3 item3,
    T4 item4,
    T5 item5,
    T6 item6,
    T7 item7)

Makes a tuple holding seven elements, which may be of different types.

Parameters

nametypedefaultdescription
item1T1—The first element.
item2T2—The second element.
item3T3—The third element.
item4T4—The fourth element.
item5T5—The fifth element.
item6T6—The sixth element.
item7T7—The seventh element.

Returns

result(T1, T2, T3, T4, T5, T6, T7)

Overload 9 of 9

Signature
Create -> ValueTuple<T1, T2, T3, T4, T5, T6, T7, (T8)>
    item1: T1
    item2: T2
    item3: T3
    item4: T4
    item5: T5
    item6: T6
    item7: T7
    item8: T8
ValueTuple<T1, T2, T3, T4, T5, T6, T7, ValueTuple<T8>> Create(
    T1 item1,
    T2 item2,
    T3 item3,
    T4 item4,
    T5 item5,
    T6 item6,
    T7 item7,
    T8 item8)

Makes a tuple holding eight elements, which may be of different types.

Parameters

nametypedefaultdescription
item1T1—The first element.
item2T2—The second element.
item3T3—The third element.
item4T4—The fourth element.
item5T5—The fifth element.
item6T6—The sixth element.
item7T7—The seventh element.
item8T8—The eighth element.

Returns

resultValueTuple<T1, T2, T3, T4, T5, T6, T7, (T8)>

Remarks

The eighth element is stored in a nested one-element tuple (the Rest field), as every tuple of more than seven elements is; ValueTupleRoutines.Length, ValueTupleRoutines.Get and ValueTupleRoutines.ToArray look through the nesting and count it as eight elements.

Ships with
Divooka ExploreDivooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
Value Tuple Routines
Package
Standard Library

Equals

Function

Whether two tuples of the same type hold equal elements, position by position, using each element type's default equality.

Signature
Equals(left: TTuple, right: TTuple) -> Truth
bool Equals(TTuple left, TTuple right)

Parameters

nametypedefaultdescription
leftTTuple—The first tuple.
rightTTuple—The second tuple.

Returns

resultTruth
Ships with
Divooka ExploreDivooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
Value Tuple Routines
Package
Standard Library

Format

Function

Writes a tuple as text, its elements separated by commas inside parentheses, for example (1, apple, True).

Signature
Format(tuple: Any) -> Text
string Format(object tuple)

Parameters

nametypedefaultdescription
tupleAny—The tuple to write. Null throws System.ArgumentNullException and a value that is not a tuple throws System.ArgumentException.

Returns

resultText
Ships with
Divooka ExploreDivooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
Value Tuple Routines
Package
Standard Library

Get

Function

The element at a position in a tuple, counting from zero; use ValueTupleRoutines.TryGet when the position may be out of range.

Signature
Get(tuple: Any, index: Integer) -> Any
object Get(object tuple, int index)

Parameters

nametypedefaultdescription
tupleAny—The tuple to read. Null throws System.ArgumentNullException and a value that is not a tuple throws System.ArgumentException.
indexInteger—The zero-based position; a position below zero or at or past the tuple's length throws System.IndexOutOfRangeException.

Returns

resultAny
Ships with
Divooka ExploreDivooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
Value Tuple Routines
Package
Standard Library

Hash

Function

A hash code combining the tuple's elements, so equal tuples get equal codes; use it for bucketing or quick inequality checks.

Signature
Hash(tuple: Any) -> Integer
int Hash(object tuple)

Parameters

nametypedefaultdescription
tupleAny—The tuple to hash; null answers 0.

Returns

resultInteger

Remarks

The code is randomised per process, so do not store it or compare it across runs. This does not check that the value is a tuple: any other value answers its own hash code.

Ships with
Divooka ExploreDivooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
Value Tuple Routines
Package
Standard Library

Is Tuple

Function

Whether Value is a tuple, so the other tuple routines can read it.

Signature
IsTuple(value: Any) -> Truth
bool IsTuple(object value)

Parameters

nametypedefaultdescription
valueAny—The value to check; null answers false.

Returns

resultTruth

Remarks

This accepts any value that exposes its elements by position, which includes the older reference-type System.Tuple classes as well as value tuples; ValueTupleRoutines.IsTupleType is stricter and accepts only value tuple types.

Ships with
Divooka ExploreDivooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
Value Tuple Routines
Package
Standard Library

Is Tuple Type

Function

Whether Type is a value tuple type of any size, from the empty tuple up to seven elements plus a nested rest; for checking a type before you have a value of it.

Signature
IsTupleType(type: Type) -> Truth
bool IsTupleType(Type type)

Parameters

nametypedefaultdescription
typeType—The type to check; null answers false. The reference-type System.Tuple classes answer false.

Returns

resultTruth
Ships with
Divooka ExploreDivooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
Value Tuple Routines
Package
Standard Library

Length

Function

How many elements a tuple holds, counting through the nested rest of a tuple with more than seven elements.

Signature
Length(tuple: Any) -> Integer
int Length(object tuple)

Parameters

nametypedefaultdescription
tupleAny—The tuple to measure. Null throws System.ArgumentNullException and a value that is not a tuple throws System.ArgumentException.

Returns

resultInteger
Ships with
Divooka ExploreDivooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
Value Tuple Routines
Package
Standard Library

Structural Compare

Function

Orders two tuples element by element like ValueTupleRoutines.Compare, with Comparer ordering each pair of elements, for example to sort text elements case-insensitively.

Signature
StructuralCompare -> Integer
    left: Any
    right: Any
    comparer: IComparer
int StructuralCompare(
    object left,
    object right,
    IComparer comparer)

Parameters

nametypedefaultdescription
leftAny—The first tuple; null or a value that does not support structural comparison throws System.ArgumentException.
rightAny—The second tuple; null sorts before any tuple, and a tuple of a different type throws System.ArgumentException.
comparerIComparer—The comparer that orders each pair of elements; null throws System.ArgumentNullException.

Returns

resultInteger
Ships with
Divooka ExploreDivooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
Value Tuple Routines
Package
Standard Library

Structural Equals

Function

Whether two tuples hold equal elements, position by position, with Comparer deciding each pair, for example to compare text elements case-insensitively.

Signature
StructuralEquals -> Truth
    left: Any
    right: Any
    comparer: IEqualityComparer
bool StructuralEquals(
    object left,
    object right,
    IEqualityComparer comparer)

Parameters

nametypedefaultdescription
leftAny—The first tuple; null or a value that does not support structural comparison throws System.ArgumentException.
rightAny—The second tuple; null, or a tuple of a different type, answers false.
comparerIEqualityComparer—The comparer that decides whether two elements are equal; null throws System.ArgumentNullException.

Returns

resultTruth
Ships with
Divooka ExploreDivooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
Value Tuple Routines
Package
Standard Library

Structural Hash

Function

A hash code for a tuple in which each element is hashed by Comparer, to pair with ValueTupleRoutines.StructuralEquals using the same comparer, for example to treat text elements case-insensitively.

Signature
StructuralHash -> Integer
    tuple: Any
    comparer: IEqualityComparer
int StructuralHash(object tuple, IEqualityComparer comparer)

Parameters

nametypedefaultdescription
tupleAny—The tuple to hash; null or a value that does not support structural comparison throws System.ArgumentException.
comparerIEqualityComparer—The comparer that hashes each element; null throws System.ArgumentNullException.

Returns

resultInteger
Ships with
Divooka ExploreDivooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
Value Tuple Routines
Package
Standard Library

To Array

Function

Copies a tuple's elements into a new array in order, so they can be handled as a list.

Signature
ToArray(tuple: Any) -> Any Array
object[] ToArray(object tuple)

Parameters

nametypedefaultdescription
tupleAny—The tuple to copy. Null throws System.ArgumentNullException and a value that is not a tuple throws System.ArgumentException.

Returns

resultAny Array
Ships with
Divooka ExploreDivooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
Value Tuple Routines
Package
Standard Library

Try Get

Function

Reads the element at a position in a tuple without throwing, telling you whether there was one.

Signature
TryGet -> (result: Truth, value: Any)
    tuple: Any
    index: Integer
bool TryGet(object tuple, int index, out object value)

Parameters

nametypedefaultdescription
tupleAny—The tuple to read; null or a value that is not a tuple answers false.
indexInteger—The zero-based position; out of range answers false.

Returns

resultTruth
valueAny
Ships with
Divooka ExploreDivooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
Value Tuple Routines
Package
Standard Library

Validate Tuple

Function

Checks that a value is a tuple and throws if it is not, so a graph fails at a clear point instead of further on.

Signature
ValidateTuple(tuple: Any)
void ValidateTuple(object tuple)

Parameters

nametypedefaultdescription
tupleAny—The value to check. Null throws System.ArgumentNullException and a value that is not a tuple throws System.ArgumentException.
Ships with
Divooka ExploreDivooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
Value Tuple Routines
Package
Standard Library