4 ms·
The default is 1, but... > Julia supports arrays with arbitrary indices. https://docs.julialang.org/en/latest/devdocs/offset-arrays/ https://docs.julialang.or
by chriskanan 8y ago
The default is 1, but...
> Julia supports arrays with arbitrary indices.
https://docs.julialang.org/en/latest/devdocs/offset-arrays/ https://docs.julialang.org/en/latest/devdocs/offset-arrays/
I personally haven't had any problem with 1-indexing when I used to program a lot in MATLAB. Maybe that's because I first learned to program using QuickBasic, which has 1-indexing. I don't understand the passion for 0-indexing (I know the arguments).
- m4r35n357 8y agoOuch, I didn't understand one bit of that document!
- bb88 8y agoFrom that document: This code implicitly assumes that vectors are indexed from 1; if dest starts at a different index than src, there is a chance that this code would trigger a segfault. (If you do get segfaults, to help locate the cause try running julia with the option --check-bounds=yes.) So it comes with a tradeoff, namely that if someone else chose different bounds on an array other than [1..n] and you try to access it the standard way, you'll get a segfault. This would scare me away from using anything other than the default indexing on an array in Julia.