Idk typing +1 seems easy enough... 1:N == union(1:(N÷2), (N÷2+1):N).
But really, these discussions are funny to me - each side pretending their convention is how God intended indexing to be done. You see it's naturally composable because N/2 shows up twice, which is really the perfect amount of times to show up, and as you recall I just defined composable in that way (not to mention it matches the fact that N/2 occurs twice in [0, N)!)
Re:Julia 1.9.0 lives up to its promise
by Iwan-Zotow on Saturday May 13, 2023 @06:49PM
(#35933572)
In python this is natural way to do ranges, and in Julia you have to remember this pesky +1
In Python (C, C++ with whole STL) you could split in the middle, or at any M
[0...N)=[0...M)+[M...N)
You could split it k times at any boundaries, still
[0...N)=[0...M1)+...+[Mk...N)
Another important thing is that number of elements to process is exactly the difference between last and first index of the range
> number of elements to process is exactly the difference between last and first index of the range
And in Julia, it’s
length(a:b)
which also works with non-unit step sizes like length(a:x:b)
The intent of these expressions seems clearer than the intent of `b-a` and `ceiling((b-a)/x)` with your proposed approach in a zero-indexed language.
You cannot do easily [0...N) = [0...N/2) + [N/2...N)