tuple_insertT_tuple_insertTupleInsertTupleInserttuple_insert (Operator)
Name
tuple_insertT_tuple_insertTupleInsertTupleInserttuple_insert
— Inserts one or more elements into a tuple at index.
Signature
def tuple_insert(tuple: MaybeSequence[Union[float, int, str]], index: int, insert_tuple: MaybeSequence[Union[float, int, str]]) -> Sequence[Union[float, int, str]]
Description
tuple_inserttuple_insertTupleInsertTupleInsertTupleInserttuple_insert
inserts the elements of the tuple InsertTupleInsertTupleInsertTupleInsertTupleinsertTupleinsert_tuple
at index into the tuple TupleTupleTupleTupletupletuple
and returns them in the tuple
ExtendedExtendedExtendedExtendedextendedextended
.
In this context IndexIndexIndexIndexindexindex
determines the start index of the elements
and InsertTupleInsertTupleInsertTupleInsertTupleinsertTupleinsert_tuple
the values to insert. Successive values of
TupleTupleTupleTupletupletuple
will be positioned after the inserted values of
InsertTupleInsertTupleInsertTupleInsertTupleinsertTupleinsert_tuple
.
The parameter IndexIndexIndexIndexindexindex
must contain a single integer value
(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 IndexIndexIndexIndexindexindex
contains the
length of TupleTupleTupleTupletupletuple
as index, InsertTupleInsertTupleInsertTupleInsertTupleinsertTupleinsert_tuple
will be
appended.
The length of the result tuple ExtendedExtendedExtendedExtendedextendedextended
is always the sum of
the two input tuples TupleTupleTupleTupletupletuple
and InsertTupleInsertTupleInsertTupleInsertTupleinsertTupleinsert_tuple
.
For example, if TupleTupleTupleTupletupletuple
contains the values [0,1,0,1,0,1],
the IndexIndexIndexIndexindexindex
contains the value [3] and the
InsertTupleInsertTupleInsertTupleInsertTupleinsertTupleinsert_tuple
contains the values [2,2,2], then the output
tuple ExtendedExtendedExtendedExtendedextendedextended
will contain the values [0,1,0,2,2,2,1,0,1].
It is allowed to mix strings and numbers in the input tuples
TupleTupleTupleTupletupletuple
and InsertTupleInsertTupleInsertTupleInsertTupleinsertTupleinsert_tuple
.
Exception: Empty input tuples
If any of the input tuples is empty, an exception is raised.
HDevelop In-line Operation
HDevelop provides an in-line operation for tuple_inserttuple_insertTupleInsertTupleInsertTupleInserttuple_insert
,
which can be used in an expression in the following syntax:
Extended := insert(Tuple, Index, InsertTuple)
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
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.
IndexIndexIndexIndexindexindex
(input_control) integer →
HTupleintHTupleHtuple (integer) (int / long) (Hlong) (Hlong)
Start index of elements to be inserted.
InsertTupleInsertTupleInsertTupleInsertTupleinsertTupleinsert_tuple
(input_control) tuple(-array) →
HTupleMaybeSequence[Union[float, int, str]]HTupleHtuple (integer / real / string) (int / long / double / string) (Hlong / double / HString) (Hlong / double / char*)
Element(s) to insert at index.
ExtendedExtendedExtendedExtendedextendedextended
(output_control) tuple-array →
HTupleSequence[Union[float, int, str]]HTupleHtuple (integer / real / string) (int / long / double / string) (Hlong / double / HString) (Hlong / double / char*)
Tuple with inserted elements.
Alternatives
tuple_concattuple_concatTupleConcatTupleConcatTupleConcattuple_concat
,
tuple_replacetuple_replaceTupleReplaceTupleReplaceTupleReplacetuple_replace
,
tuple_gen_consttuple_gen_constTupleGenConstTupleGenConstTupleGenConsttuple_gen_const
See also
tuple_removetuple_removeTupleRemoveTupleRemoveTupleRemovetuple_remove
Module
Foundation