Skip to content

tuple_replaceTupleReplaceTupleReplacetuple_replaceT_tuple_replace🔗

Short description🔗

tuple_replaceTupleReplaceTupleReplacetuple_replaceT_tuple_replace — Replaces one or more elements of a tuple.

Signature🔗

tuple_replace( tuple Tuple, integer Index, tuple ReplaceTuple, out tuple Replaced )void TupleReplace( const HTuple& Tuple, const HTuple& Index, const HTuple& ReplaceTuple, HTuple* Replaced )static void HOperatorSet.TupleReplace( HTuple tuple, HTuple index, HTuple replaceTuple, out HTuple replaced )def tuple_replace( tuple: MaybeSequence[Union[float, int, str]], index: MaybeSequence[int], replace_tuple: MaybeSequence[Union[float, int, str]] ) -> Sequence[Union[float, int, str]]

Herror T_tuple_replace( const Htuple Tuple, const Htuple Index, const Htuple ReplaceTuple, Htuple* Replaced )

HTuple HTuple::TupleReplace( const HTuple& Index, const HTuple& ReplaceTuple ) const

HTuple HTuple.TupleReplace( HTuple index, HTuple replaceTuple )

Description🔗

tuple_replaceTupleReplace replaces one or more elements of the input tuple Tupletupletuple and returns them with Replacedreplacedreplaced. At this, Indexindexindex determines the indices of the elements and ReplaceTuplereplaceTuplereplace_tuple the corresponding values to replace. The parameter Indexindexindex must contain one or more integer values (any floating point number must represent an integer value without fraction). Indices of tuple elements start at 0. Therefore, the first tuple element has got the index 0. If ReplaceTuplereplaceTuplereplace_tuple contains only one value, this value will be replaced at all indices of Indexindexindex. If a value of Indexindexindex is greater than the length of the input tuple Tupletupletuple, Replacedreplacedreplaced will be extended accordingly and initialized with zeros. For example, if Tupletupletuple contains [1], Indexindexindex contains the values [2,4], and ReplaceTuplereplaceTuplereplace_tuple contains the values [3,5], Replacedreplacedreplaced will be [1,0,3,0,5].

It is allowed to mix strings and numbers in the input tuples Tupletupletuple and ReplaceTuplereplaceTuplereplace_tuple.

Exception: Empty input tuples🔗

If either Indexindexindex or ReplaceTuplereplaceTuplereplace_tuple is empty and the other is not, an exception is raised. If both are empty, the output tuple Replacedreplacedreplaced corresponds to the input Tupletupletuple. If both are empty, but the input Tupletupletuple is not, the empty tuple will be extended as described above.

HDevelop In-line Operation🔗

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

Replaced := replace(Tuple, Index, ReplaceTuple)

Execution information🔗

Execution information
  • Multithreading type: reentrant (runs in parallel with non-exclusive operators).

  • Multithreading scope: global (may be called from any thread).

  • Processed without parallelization.

Parameters🔗

Tupletupletuple (input_control) tuple(-array) → (integer / real / string)HTuple (Hlong / double / HString)HTuple (int / long / double / string)MaybeSequence[Union[float, int, str]]Htuple (Hlong / double / char*)

Input tuple.

Indexindexindex (input_control) integer(-array) → (integer)HTuple (Hlong)HTuple (int / long)MaybeSequence[int]Htuple (Hlong)

Index/Indices of elements to be replaced.

ReplaceTuplereplaceTuplereplace_tuple (input_control) tuple(-array) → (integer / real / string)HTuple (Hlong / double / HString)HTuple (int / long / double / string)MaybeSequence[Union[float, int, str]]Htuple (Hlong / double / char*)

Element(s) to replace.

Replacedreplacedreplaced (output_control) tuple-array → (integer / real / string)HTuple (Hlong / double / HString)HTuple (int / long / double / string)Sequence[Union[float, int, str]]Htuple (Hlong / double / char*)

Tuple with replaced elements.

Combinations with other operators🔗

Combinations

Alternatives

tuple_selectTupleSelect, tuple_first_nTupleFirstN, tuple_last_nTupleLastN, tuple_select_maskTupleSelectMask, tuple_str_bit_selectTupleStrBitSelect, tuple_concatTupleConcat, tuple_select_rankTupleSelectRank

See also

tuple_removeTupleRemove, tuple_insertTupleInsert

Module🔗

Foundation