“Programming In Scala” explains that tuples’
_N numbers are one-based, instead of zero-based, because starting with 1 is
a tradition set by other languages
with statically typed tuples such as
Haskell and ML
but this can hardly be called an explanation.
Why were tuples defined as 1-based in Haskell and ML in the first place?
Are there any mathematical/programming benefits in having 1-based indexed tuples and not 0-based?
Thanks,
Ori
I guess
_1,_2etc it is short for “first”, “second”, and so on. (fstandsndfor instance have historically been used for accessing the left and right part of a tuple). The index in an array on the other hand is an offset and the first element is usually at offset 0.No. The elements are not accessed programatically anyway. (You can’t do
_iifiis an integer.)