Skip to main content

map_negative_indices

No overview available.

def map_negative_indices(
indices: list,
length: int
) - > list

Converts negative index values into their positive equivalents based on the total length of a sequence.

Parameters

NameTypeDescription
indiceslistA list of integers representing sequence positions, which may include negative values for end-relative indexing.
lengthintThe total number of elements in the target sequence used to calculate positive offsets.

Returns

TypeDescription
listA list of non-negative integers where negative inputs have been offset by the sequence length.