Steven D'Aprano <[EMAIL PROTECTED]> wrote: > Steve Kramer <[EMAIL PROTECTED]> wrote: > > > > In refernce to incrementing the variable in a repeat loop to process > > every third line, why not just have the following? > > > > repeat with n=1 to somenum > > if n mod(3) <> 0 then next repeat > > do whatever > > end repeat > > Firstly, it's not as clear what this routine is doing. Ongoing > maintainence of large software projects is much more expensive than > creating the software in the first place, and anything which makes it > more difficult to understand code that you wrote two years ago is a Bad > Thing. > > Secondly, there is a performance penalty in doing things this way. I > tested the incremental step size method (add step_size to step_var) > versus this modulo method and found that the modulo method was 4.5 times > slower. This may be beating the proverbial dead horse, but... Just as fast as incrementing the 'repeat with' loop variable, and even clearer, is the following: put 0 into n repeat until n >= somenum # or whatever conditional test for finality add 3 to n do whatever end repeat This construct does not additionally increment an automatically incrementing repeat loop, which was the basic objection to the original suggestion. Steve Kramer
begin:vcard n:Kramer;Stephen tel;fax:(212) 312-4958 tel;work:(212) 312-4851 x-mozilla-html:FALSE org:Stuyvesant High School adr:;;345 Chambers Street;New York;NY;10282; version:2.1 email;internet:[EMAIL PROTECTED] title:Assistant Principal Technology Services note:Stuyvesant High School, America's First Science/Math High School, was founded in 1904. x-mozilla-cpt:;3 fn:Stephen Kramer end:vcard
