Returns the real index for a modulo index.

var a = [10,20,30]
assert a.modulo_index(1) == 1
assert a.modulo_index(3) == 0
assert a.modulo_index(-1) == 2
assert a.modulo_index(-10) == 2

REQUIRE not_empty

Property definitions

core $ SequenceRead :: modulo_index
	# Returns the real index for a modulo index.
	#
	# ~~~
	# var a = [10,20,30]
	# assert a.modulo_index(1) == 1
	# assert a.modulo_index(3) == 0
	# assert a.modulo_index(-1) == 2
	# assert a.modulo_index(-10) == 2
	# ~~~
	#
	# REQUIRE `not_empty`
	fun modulo_index(index: Int): Int
	do
		var length = self.length
		if index >= 0 then
			return index % length
		else
			return length - (-1 - index) % length - 1
		end
	end
lib/core/collection/abstract_collection.nit:881,2--900,4