[CentralOH] 2017-10-26 道場 Scribbles 落書/惡文? Idiomatic Loops: i < n versus i <= n - 1; json

R P Herrold herrold at owlriver.com
Fri Oct 27 11:17:51 EDT 2017


On Fri, 27 Oct 2017, jep200404 at columbus.rr.com wrote:

> For terminating loops, i < n is the standard idiom, not i <= n - 1.

> See page 12 of "The Practice of Programming" by Kernighan & Pike.

This is probably a caveat from another era -- modern 
language designers noticed this, and a 'forall', or 'foreach' 
construct is present in perl, php, modern C++, and so forth, 
helping 'verifiability' of code by moving to 'all in a set' 
type specification (more mathematical, in the sense  of 'set 
theory')
 
-- Russ herrold


More information about the CentralOH mailing list