titus.util.negativeIndex

titus.util.negativeIndex(length, index)[source]

Helper function for interpreting negative array indexes as counting from the end of the array (just like Python).

Parameters:
  • length (non-negative integer) – length of the array in question
  • index (integer) – index to interpret
Return type:

non-negative integer

Returns:

if negative, count from the end of the array; otherwise, pass-through