Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

/prog/ feels thread

Name: Anonymous 2012-10-16 12:55

that feel when your CS lecturer starts loops from 1 instead of 0.

Name: Anonymous 2012-10-16 20:27

One-based arrays and loops are more natural because empty arrays exist in nature. The first N numbers are 1,2,3...N. The length of this list is N, the upper bound is N and the maximum value is N. If N is 0, the list is empty. If arrays start from 1, the upper bound and length of any array are the same. For an empty array, the upper bound would be 0. No negative integers are necessary for one-based arrays, so anything involving array indices or lengths can be unsigned. Inclusive ranges are also more natural. When someone mentions lowercase letters, you think "a".."z" and not "a"..chr 1+ord "z". If you consider a loop over the integers included in a one-based numeric range, such as 1..10, the loop will repeat as many times as the second integer. With 1..1 it loops once, and with 1..0 it is not executed at all.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List