| I am starting to think Dijkstra is about the worst thing ever happening to software development. He arguments that option A is the least ugly one, but forgets that computers have maximum numbers. According to Dijkstra, you should test if a variable is a valid integer like: 0 <= var < MaxInt + 1. The best possible outcome of such a test would be a compiler error. His argument that sequences defined as min <= i < (max + 1) because (max + 1) - min = total number of items is just silly. Maybe true for maths, not so for programmers. When reading code, you want to know if the code is valid, not how many items there are in a list. And reading i <= Max instead of i < (max + 1) is simpler. Secondly, his article is about 0 or 1 based arrays, not random selections. And in case of 1 based arrays, the max = total number of elements. So option C is best. About whether 0 or 1 based arrays are better. They both have their uses. 0 based for spatial coordinates, 1 based for lists and character positions. |
2) You frequently want to know the length of a subseq, and you frequently want successive subseq ranges to dovetail.
3) What in the world does rand() have to do with this?