Why Python's Range to be designed to close the left and right open?

In general: represents 2, 3, ..., 12 string natural number which has the following four methods:

a)2 ≤ i < 13

b)1 < i ≤ 12

c)2 ≤ i ≤ 12

d)1 < i < 13

Let me have a 5:00 at the reasons:

  • Mesa (Reference 1) practical application, a first well;
  • a, b before and two kinds of upper and lower boundaries is just equal to the length of the columns;
  • Represents the number of neighboring columns, the number of columns on the lower front boundary and the rear boundary of the boundary is equal to ([2,13) ​​and [13,15) adjacent or (1, 12] and (12, 15]))
  • If B, it would be not natural to represent a natural number, since the minimum number is zero, to represent the number zero, the number of the boundary must be -1, (- 1,5] first method the [0,6) compared to, obviously a good;
  • Dichotomy in use, the interval [2,8], about interval [2,5], [5,8], more than 5, the results of the algorithm are not allowed, some people say can write [2,5 ], [6,8]. It is possible, but also at the time of binary data processing to do between partitions.

Reference links:

https://www.cs.utexas.edu/users/EWD/transcriptions/EWD08xx/EWD831.html

https://www.jianshu.com/p/5eaa330788e8

https://www.zhihu.com/question/24883243

Guess you like

Origin www.cnblogs.com/benjieqiang/p/11406982.html