
1: Fortran
(Defaults to 1, but you can make set it to be 0 if you want. Or 50. Or (-37). Or any other integer).
@nixCraft Nope.
But Wikipedia can!
https://en.m.wikipedia.org/wiki/Comparison_of_programming_languages_(array)
(FWIW I only got Fortran right.)
@Serpent7776 @nixCraft Maybe 'Brainfuck' ? :D
Just a guess...
@nixCraft #Perl versions prior to 2019βs v5.30.0 let you change the base index value with the $[ special variable, mainly to placate #AWK migrations: https://perldoc.perl.org/variables/$%5B
(It had been deprecated since 2010βs v5.12.0)
@demiguise @nixCraft It had always been discouraged since #Perl 5.000βs release in 1994: https://github.com/Perl/perl5/blob/a0d0e21ea6ea90a22318550944fe6cb09ae10cda/pod/perlvar.pod#user-content-pod27
As to βwhyββyouβd have to ask either #LarryWall or #AndyDougherty.
@mjgardner @demiguise @nixCraft I believe it was because it was so fragile. If you didn't scope it correctly, it could break all arrays.
Even if you did scope it correctly, it could break programmer's brains because if you didn't see that indexing started with zero, it would be very easy to mishandle arrays.
@nixCraft A few I know of include:
1. Lua
2. Zsh
3. CSS Grid properties
@nixCraft I think in awk you can index with whatever you like.
From "first" over "-1" to "infinity"
Testing...
Yes.
:/data/user/0/com.termoneplus/app_HOME $
:/data/user/0/com.termoneplus/app_HOME $ awk 'BEGIN{
> a["first"]="hello"
> a[-1]="not"
> a["infinity"]="a lot"
>
> for (i in a) {
> print i " " a[i]
> }
> }'
first hello
infinity a lot
-1 not
:/data/user/0/com.termoneplus/app_HOME $