On Wed, 23 Aug 2006, Dominick Samperi wrote:

> In for loops of the form:
> for(m in seq(beg,end))
> ...
>
> when beg > end, the default behavior is
> to decrement, and the action described
> by ... is executed at least once.
>
> On the other hand, if you view this
> construction as a translation of the C code:
> for(m = beg; m < end; m++)
> ...
>
> then the semantics of C/C++ is not
> respected, because the code in ... is
> not executed when beg > end in
> the case of C/C++.

There is another important way in which the C loop is different 
from the R loop.  If you modify m or end inside the loop the number of 
iterations of the C loop changes but the number of iterations of the R 
loop doesn't.  R's for() loop just isn't the same as C's.

        -thomas

Thomas Lumley                   Assoc. Professor, Biostatistics
[EMAIL PROTECTED]       University of Washington, Seattle

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to