3 ms·
Depends on what you work on. When doing more computer science like stuff, such as computing memory offsets etc, then 0-based indexing is practical. But for nume
by socialdemocrat 7y ago
Depends on what you work on. When doing more computer science like stuff, such as computing memory offsets etc, then 0-based indexing is practical. But for numerical work 1-based indexing is usually easier to work with. Mathematical texts are already using 1-based indexing and hence that is what people are used to when thinking about math.
I work with both and I never found this a big problem. This is on par with complaining about whitespace in Python. I prefer languages to not be whitespace sensitive but it is not a big problem.
Although I pretty sure you will accidentally get more problem from Python whitespace usage than from Julia 1-based indexing.
And frankly since Julia can use any indexing, you can use A[begin:end] to refer to the whole range of an object. If you want the second item in any array you can just write A[begin+1].
- giornogiovanna 7y ago> But for numerical work 1-based indexing is usually easier to work with. That's not really true in my experience, since all the nice properties of zero-based indexing transfer perfectly over to mathematics. But you're right, this isn't anything to abandon an otherwise wonderful language over.
- wnoise 7y ago> Mathematical texts are already using 1-based indexing For matrices and vectors, usually. For series and sequences 0-based comes up quite often too.
- Iwan-Zotow 7y agoWhatever I'm doing this is wrong. Simple example - I have Python sequence [0...N) to process. If members are independent, I could split it with easy in Python and do it in parallel: [0...N) -> [0...M) + [M...N) for any M between 0 and N. Basically, Python sequences/ranges/etc are monoids in many cases. Simplest composition rule - monoid, with unit element and associative composition. In Julia it really looks ugly, you have to make some effort to do it right. For me, Julia people don't get range/sequence composition right, so ...
- JustFinishedBSG 7y agoYou're inventing problems that don't exist. Every thing you said is applicable exactly with 1, 2 or whatever based indexing. It literally doesn't matter. Julia's sequences/arrays are monoids too, I don't see what it has to do with anything.
- Iwan-Zotow 7y ago> Every thing you said is applicable exactly with 1, 2 or whatever based indexing. read my statement again, it is about open vs closed interval. Python ranges/sequences are composable, Julia ones are not. > Julia's sequences/arrays are monoids too really? suppose you compute sum, and got two results: S(1, M) and S(M, N) Could you compose them in Julia?
- newen 7y agoYou compute S(1, M-1) and S(M, N) instead and compose them. That's it. This is not complicated stuff.