In math.SE, the question of mathematical notation discussed the question of how programming languages interpret the set {1, ..., n} when n = 0
The question is given a mathematical notation for representing the R-code 1:n
According to the comments, the mathematical interpretation of {1, ..., n} for n = 0 is that it is an empty set. The following comment suggested that C is consistent with this interpretation because for (int i = 1; i < n; i++)
returns an empty set because it iterates 0 times.
It is not clear to me that there is an equivalent instruction in R, but 1:0
returns the vector [1,0]
So for (i in 1:0) print(i)
iterates over 1 and 0 (I interpret it like C code above)
Is this because {1, ..., n} is not the correct notation for 1:n
?
Does this mean that R violates the universal rule?
Is there a consistent interpretation of this set among programming languages?
source share