Closed Maltysen closed 8 years ago
I don't see why this is a problem.
@ConorOBrien-Foxx array indexing, (I'm guessing, based on js) will be 0-indexed, so the ranges should also be 0-indexed, which means that the end should not be inclusive.
Why does that follow ?
@ConorOBrien-Foxx what happens when you want to loop through an array of len n
? the indices of that array are 0..n-1
other langs have inclusive range, but then they need to make everything 1-indexed. (example, APL)
Okay? I still don't see your point. In a range m:n, n is often not the length of the range.
@ConorOBrien-Foxx but you will be indexing up to n
for that array, but the last index is n-1
, so the last number returned from :
should be n-1
Could you maybe rephrase? Perhaps I'll understand then.
Oh, I see. It's customary.
Fixed by making monadic range do this.
Current Behavior
Desired Behavior
2:10
giving[2,3,4,5,6,7,8,9]
and4:4
giving[]
because now,
0:n
has a length ofn+1
, notn