Closed osaatcioglu closed 7 years ago
Hi @osaatcioglu, thanks for the bugfix. The sublist was not actually a bug - I actually think it makes a lot more sense that the indexes you specify form a closed interval, i.e. the numbers you actually specify correspond directly to the sublist you get out. I know that a lot of other languages don't do this but I believe this is one of those arbitrary decisions that's continued without much thought. I've reverted the sublist changes but I'm really glad you noticed the nth bug!
Thanks for the merge. About the sublist, I suspected that you would have a different opinion as it was too obvious in the code but I didn't come to a conclusion right away. :)
I respectfully disagree with your decision. Because, I think the common approach makes more sense when you take the start of the index as 0. So that, the complete list can be reached like this [0 to len(list)] rather than [0 to len(list) - 1]. I believe the latter looks a bit weird.
But if we had taken the start of index as 1, then we would use the following expression to reach the complete list [1 to len(list)]. I am not sure I am ready to take this leap though. :)
I think, this is more of a philosophical debate rather than a technical. So, I will respect your decision as the creator of the language and I follow your lead on this one. :)
Just to add a bit of humour and warn ourselves that we are swimming in dangerous waters here. :)
No I see your point, but actually I'm trying to address an arbitrary choice. Your logic that arrays go from 0 to len(a) - 1
doesn't actually translate to the idea of describing a sublist however. What I'm suggesting is that when I ask for a list of elements by index I get back a list which corresponds to the numbers I used to ask for that sub list. So if I want all elements of a list with indexes 0 - 5, I use (sublist some-list 0 5)
, and not (sublist some-list 0 one-more-than-what-i-want)
.
So not at all that "arrays start at 1", but instead that sublists are described by a closed interval vs a half open interval
I understand your point really. So, we are good.
Bug Fix: Can’t reach the 0th element in the list with the nth function Bug Fix: The end element shouldn’t be included in the sub list (I am not sure if this is intentional but most of the programming languages exclude the end index) Update the sublist example and a small syntax error in README file