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.

(If anyone wants the source code for this, please email me.)

Of course, in a real life example, the time taken by the repeat loop
itself will be incidental to the processing time done in the loop, so
the difference may not worry you.

Warren Ockrassa <[EMAIL PROTECTED]> wrote:

> Or you could get really clever and assume implicite negation:
> 
>   repeat with nIncrement = 1 to nTarget
>   if nIncrement mod(3) then next repeat
>   doYourThing
>   end repeat

Too clever by half :-) See my comments above about on-going
maintainence. Remember the KISS principle.


-- 
Steven D'Aprano

==========================================
M.B. Sales Pty Ltd    Ph:  +61 3 9460-5244
A.C.N. 005-964-796    Fax: +61 3 9462-1161

Reply via email to