tuple_uniqtuple_uniqTupleUniqTupleUniqtuple_uniq (Operator)

Name

tuple_uniqtuple_uniqTupleUniqTupleUniqtuple_uniq — Discard all but one of successive identical elements of a tuple.

Signature

tuple_uniq( : : Tuple : Uniq)

Herror tuple_uniq(const Hlong Tuple, Hlong* Uniq)

Herror T_tuple_uniq(const Htuple Tuple, Htuple* Uniq)

void TupleUniq(const HTuple& Tuple, HTuple* Uniq)

HTuple HTuple::TupleUniq() const

static void HOperatorSet.TupleUniq(HTuple tuple, out HTuple uniq)

HTuple HTuple.TupleUniq()

def tuple_uniq(tuple: MaybeSequence[Union[float, int, str]]) -> Sequence[Union[float, int, str]]

def tuple_uniq_s(tuple: MaybeSequence[Union[float, int, str]]) -> Union[float, int, str]

Description

tuple_uniqtuple_uniqTupleUniqTupleUniqTupleUniqtuple_uniq discards all but one of successive identical elements from the input tuple TupleTupleTupleTupletupletuple and returns the remaining elements in UniqUniqUniqUniquniquniq. For example, if TupleTupleTupleTupletupletuple contains the values [0,0,1,1,1,2,0,1], the output tuple UniqUniqUniqUniquniquniq will contain the values [0,1,2,0,1]. It is allowed to mix strings and numbers in the input tuple.

To get a tuple UniqUniqUniqUniquniquniq that contains all different entries of TupleTupleTupleTupletupletuple exactly once, use the operator tuple_sorttuple_sortTupleSortTupleSortTupleSorttuple_sort first. Note however that in this case the output tuple UniqUniqUniqUniquniquniq is sorted. The result of the above example then is [0,1,2].

Exception: Empty input tuple

If the input tuple is empty, the operator returns an empty tuple.

HDevelop In-line Operation

HDevelop provides an in-line operation for tuple_uniqtuple_uniqTupleUniqTupleUniqTupleUniqtuple_uniq, which can be used in an expression in the following syntax:

Uniq := uniq(Tuple)

As mentioned above, you can use tuple_sorttuple_sortTupleSortTupleSortTupleSorttuple_sort to truly get all unique elements of TupleTupleTupleTupletupletuple.

Uniq := uniq(sort(Tuple))

Execution Information

Parameters

TupleTupleTupleTupletupletuple (input_control)  tuple(-array) HTupleMaybeSequence[Union[float, int, str]]HTupleHtuple (integer / real / string) (int / long / double / string) (Hlong / double / HString) (Hlong / double / char*)

Input tuple.

UniqUniqUniqUniquniquniq (output_control)  tuple(-array) HTupleSequence[Union[float, int, str]]HTupleHtuple (integer / real / string) (int / long / double / string) (Hlong / double / HString) (Hlong / double / char*)

Tuple without successive identical elements.

Example (HDevelop)

Tuple := [0,0,1,1,1,2,0,1]
*
tuple_uniq (Tuple, Uniq)
*
tuple_sort (Uniq, Sorted)
tuple_uniq (Sorted, Uniq1)

Possible Predecessors

tuple_inversetuple_inverseTupleInverseTupleInverseTupleInversetuple_inverse, tuple_sorttuple_sortTupleSortTupleSortTupleSorttuple_sort

Alternatives

tuple_intersectiontuple_intersectionTupleIntersectionTupleIntersectionTupleIntersectiontuple_intersection

Module

Foundation