tuple_uniqtuple_uniqTupleUniqTupleUniqtuple_uniq (算子)
名称
tuple_uniqtuple_uniqTupleUniqTupleUniqtuple_uniq — 丢弃元组中除一个元素外的所有连续相同元素。
签名
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]
描述
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].
例外:空输入元组
If the input tuple is empty, the operator returns an empty tuple.
HDevelop 内联操作
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))
执行信息
- 多线程类型:独立(即使使用独占算子也能并行运行)。
- 多线程作用域:全局(可从任何线程调用)。
- 未采用并行化处理。
参数
TupleTupleTupleTupletupletuple (输入控制) tuple(-array) → HTupleMaybeSequence[Union[float, int, str]]HTupleHtuple (integer / real / string) (int / long / double / string) (Hlong / double / HString) (Hlong / double / char*)
Input tuple.
UniqUniqUniqUniquniquniq (输出控制) 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.
示例(HDevelop)
Tuple := [0,0,1,1,1,2,0,1]
*
tuple_uniq (Tuple, Uniq)
*
tuple_sort (Uniq, Sorted)
tuple_uniq (Sorted, Uniq1)
可能的前趋
tuple_inversetuple_inverseTupleInverseTupleInverseTupleInversetuple_inverse,
tuple_sorttuple_sortTupleSortTupleSortTupleSorttuple_sort
替代
tuple_intersectiontuple_intersectionTupleIntersectionTupleIntersectionTupleIntersectiontuple_intersection
模块
基础