tuple_select_rangetuple_select_rangeTupleSelectRangeTupleSelectRangetuple_select_range (Operator)
Name
tuple_select_rangetuple_select_rangeTupleSelectRangeTupleSelectRangetuple_select_range
— Select several elements of a tuple.
Signature
def tuple_select_range(tuple: MaybeSequence[Union[float, int, str]], leftindex: MaybeSequence[int], rightindex: MaybeSequence[int]) -> Sequence[Union[float, int, str]]
def tuple_select_range_s(tuple: MaybeSequence[Union[float, int, str]], leftindex: MaybeSequence[int], rightindex: MaybeSequence[int]) -> Union[float, int, str]
Description
tuple_select_rangetuple_select_rangeTupleSelectRangeTupleSelectRangetuple_select_range
selects several consecutive elements of the
input tuple TupleTupleTupletupletuple
and returns them with SelectedSelectedSelectedselectedselected
.
At this, LeftindexLeftindexLeftindexleftindexleftindex
determines the index of the first element
and RightindexRightindexRightindexrightindexrightindex
determines the index of the last element to select.
Thus, both parameters LeftindexLeftindexLeftindexleftindexleftindex
and RightindexRightindexRightindexrightindexrightindex
must
contain a single integer value (any floating point number must
represent an integer value without fraction). Indices of tuple elements
start at 0, that means, the first tuple element has got the index 0.
The result tuple SelectedSelectedSelectedselectedselected
contains every element from the
tuple TupleTupleTupletupletuple
that has got an index between LeftindexLeftindexLeftindexleftindexleftindex
and RightindexRightindexRightindexrightindexrightindex
(including the elements at position
LeftindexLeftindexLeftindexleftindexleftindex
and RightindexRightindexRightindexrightindexrightindex
). If the indices are equal,
only one element is selected.
In addition, it is possible that the right index is LeftindexLeftindexLeftindexleftindexleftindex
- 1.
In this case and if the left or right index are valid an empty tuple
is returned. Hence, the index RightindexRightindexRightindexrightindexrightindex
must be greater or
equal to LeftindexLeftindexLeftindexleftindexleftindex
- 1.
Exception: Empty input tuples
If LeftindexLeftindexLeftindexleftindexleftindex
and RightindexRightindexRightindexrightindexrightindex
are empty tuples, the operator
returns an empty tuple. If only one of those parameters or TupleTupleTupletupletuple
is an empty tuple, an exception is raised.
HDevelop In-line Operation
HDevelop provides an in-line operation for tuple_select_rangetuple_select_rangeTupleSelectRangeTupleSelectRangetuple_select_range
,
which can be used in an expression in the following syntax:
Selected := Tuple[Leftindex:Rightindex]
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.
LeftindexLeftindexLeftindexleftindexleftindex
(input_control) integer(-array) →
HTupleMaybeSequence[int]HTupleHtuple (integer) (int / long) (Hlong) (Hlong)
Index of first element to select.
RightindexRightindexRightindexrightindexrightindex
(input_control) integer(-array) →
HTupleMaybeSequence[int]HTupleHtuple (integer) (int / long) (Hlong) (Hlong)
Index of last element to select.
SelectedSelectedSelectedselectedselected
(output_control) tuple(-array) →
HTupleSequence[Union[float, int, str]]HTupleHtuple (integer / real / string) (int / long / double / string) (Hlong / double / HString) (Hlong / double / char*)
Selected tuple elements.
Alternatives
tuple_selecttuple_selectTupleSelectTupleSelecttuple_select
,
tuple_first_ntuple_first_nTupleFirstNTupleFirstNtuple_first_n
,
tuple_last_ntuple_last_nTupleLastNTupleLastNtuple_last_n
,
tuple_select_masktuple_select_maskTupleSelectMaskTupleSelectMasktuple_select_mask
,
tuple_str_bit_selecttuple_str_bit_selectTupleStrBitSelectTupleStrBitSelecttuple_str_bit_select
,
tuple_concattuple_concatTupleConcatTupleConcattuple_concat
,
tuple_select_ranktuple_select_rankTupleSelectRankTupleSelectRanktuple_select_rank
See also
tuple_removetuple_removeTupleRemoveTupleRemovetuple_remove
Module
Foundation