Changing the array base at runtime

question

#1

I intend to drive my annoying software tester into the madness.

For this, I would like to change the base of an array at runtime, between
the normal (1-based) mode and a different one (defined via OffsetArrays).

How do I do this most efficiently?


#2

Since OffsetArray is immutable, you cannot change the offsets of an existing one. Best you can do is create another one with the same contents and different offset. Or if you insist on doing the above, you need to roll your own mutable struct (doing this is pretty common for unit tests).