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_insertTupleInsertTupleInserttuple_insert
inserts the elements of the tuple InsertTupleInsertTupleInsertTupleinsertTupleinsert_tuple
at index into the tuple TupleTupleTupletupletuple
and returns them in the tuple
ExtendedExtendedExtendedextendedextended
.
In this context IndexIndexIndexindexindex
determines the start index of the elements
and InsertTupleInsertTupleInsertTupleinsertTupleinsert_tuple
the values to insert. Successive values of
TupleTupleTupletupletuple
will be positioned after the inserted values of
InsertTupleInsertTupleInsertTupleinsertTupleinsert_tuple
.
The parameter IndexIndexIndexindexindex
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 IndexIndexIndexindexindex
contains the
length of TupleTupleTupletupletuple
as index, InsertTupleInsertTupleInsertTupleinsertTupleinsert_tuple
will be
appended.
The length of the result tuple ExtendedExtendedExtendedextendedextended
is always the sum of
the two input tuples TupleTupleTupletupletuple
and InsertTupleInsertTupleInsertTupleinsertTupleinsert_tuple
.
For example, if TupleTupleTupletupletuple
contains the values [0,1,0,1,0,1],
the IndexIndexIndexindexindex
contains the value [3] and the
InsertTupleInsertTupleInsertTupleinsertTupleinsert_tuple
contains the values [2,2,2], then the output
tuple ExtendedExtendedExtendedextendedextended
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
TupleTupleTupletupletuple
and InsertTupleInsertTupleInsertTupleinsertTupleinsert_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_insertTupleInsertTupleInserttuple_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
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.
IndexIndexIndexindexindex
(input_control) integer →
HTupleintHTupleHtuple (integer) (int / long) (Hlong) (Hlong)
Start index of elements to be inserted.
InsertTupleInsertTupleInsertTupleinsertTupleinsert_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.
ExtendedExtendedExtendedextendedextended
(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_concatTupleConcatTupleConcattuple_concat
,
tuple_replacetuple_replaceTupleReplaceTupleReplacetuple_replace
,
tuple_gen_consttuple_gen_constTupleGenConstTupleGenConsttuple_gen_const
See also
tuple_removetuple_removeTupleRemoveTupleRemovetuple_remove
Module
Foundation