Whereas self[]=
requires the index to exists, the modulo
accessor automatically
wraps overbound and underbouds indexes.
var a = [10,20,30]
a.modulo(1) = 200
a.modulo(3) = 100
a.modulo(-1) = 300
a.modulo(-10) = 301
assert a == [100, 200, 301]
REQUIRE not_empty
ENSURE self[modulo_index(index)] == value
# Set the index-th element but wrap
#
# Whereas `self[]=` requires the index to exists, the `modulo` accessor automatically
# wraps overbound and underbouds indexes.
#
# ~~~
# var a = [10,20,30]
# a.modulo(1) = 200
# a.modulo(3) = 100
# a.modulo(-1) = 300
# a.modulo(-10) = 301
# assert a == [100, 200, 301]
# ~~~
#
# REQUIRE `not_empty`
# ENSURE `self[modulo_index(index)] == value`
fun modulo=(index: Int, value: E) do self[modulo_index(index)] = value
lib/core/collection/abstract_collection.nit:1182,2--1198,71