tuple_uniqtuple_uniqTupleUniqTupleUniqtuple_uniq (Operator)
Name
tuple_uniqtuple_uniqTupleUniqTupleUniqtuple_uniq
— Discard all but one of successive identical elements of a tuple.
Signature
Herror tuple_uniq(const Hlong Tuple, Hlong* Uniq)
Herror T_tuple_uniq(const Htuple Tuple, Htuple* Uniq)
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_uniqTupleUniqTupleUniqtuple_uniq
discards all but one of successive identical
elements from the input tuple TupleTupleTupletupletuple
and returns the
remaining elements in UniqUniqUniquniquniq
.
For example, if TupleTupleTupletupletuple
contains the values
[0,0,1,1,1,2,0,1], the output tuple UniqUniqUniquniquniq
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 UniqUniqUniquniquniq
that contains all different entries of
TupleTupleTupletupletuple
exactly once, use the operator tuple_sorttuple_sortTupleSortTupleSorttuple_sort
first. Note
however that in this case the output tuple UniqUniqUniquniquniq
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_uniqTupleUniqTupleUniqtuple_uniq
,
which can be used in an expression in the following syntax:
Uniq := uniq(Tuple)
As mentioned above, you can use tuple_sorttuple_sortTupleSortTupleSorttuple_sort
to truly get all
unique elements of TupleTupleTupletupletuple
.
Uniq := uniq(sort(Tuple))
Execution Information
- Multithreading type: independent (runs in parallel even with exclusive operators).
- Multithreading scope: global (may be called from any thread).
- Processed without parallelization.
Parameters
TupleTupleTupletupletuple
(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.
UniqUniqUniquniquniq
(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_inverseTupleInverseTupleInversetuple_inverse
,
tuple_sorttuple_sortTupleSortTupleSorttuple_sort
Alternatives
tuple_intersectiontuple_intersectionTupleIntersectionTupleIntersectiontuple_intersection
Module
Foundation