For as long as programmers have been programming and as long as English teachers have been teaching, there's a controversy over the datasets called Arrays and Lists (or hashes).
Arrays have almost always had their first index at 0. Which, for the programmer, is understandable because of math. But along the way, as more and more languages have appeared, and more and more people start to program, they can't wrap their mind around the array.
They know it's a table of indexes with values assigned to each index, but they don't know why it starts at 0, because 0 typically means nothing. 0 is a quantitative value that we don't see (or can, but mostly in context).
It's simple: Make your arrays/list/hashes/whatever start at one
This doesn't require special tinkering to the compiler/interpreter. Make a user's array have their expected values at position 1.
Loopholes aren't allowed.
A basic example (written in Pseudo):
list = [1,2,3] lis = [null] value = 1 Loop list Through 3 Times as Index_Value lis[value] = Index_Value value += 1 print(lis) // or return lis, doesn't matter
- No standard loopholes allowed
- Languages that have arrays/lists/hashes that start at one OR are configurable to have settable index numbers.
- Input will be given, you may expect a array. However, if the array requires certain types, assume the array is filled with integers. Basically, test for [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] (I do encourage any answers that aren't for competition)
- Output must be the fixed array. If the fixed array is assigned to value
a == 1
- Anything can be in the
aindex, the user will not care. Though, preferably, BUT NOT REQUIRED, the value should be
nullor some other comparable value.
This is code-golf, so the shortest answer in bytes wins.