Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: A Mata question (2).


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: A Mata question (2).
Date   Mon, 28 Nov 2005 18:09:22 -0000

I believe that there is no difference
in this case. It is a common convention
to write i++, not ++i, but that's 
just that, a common convention. 

On the principle that 

for(exp1; exp2; exp3) { 
	stmt(s)
} 

is equivalent to

        exp1
        while (exp2) {
                stmt(s)
                exp3
        }

the results of a -for- loop will not vary 
as long as different exp3 have the same results. 

In your case this is true of i++ and ++i
but I guess someone could come up with exp3 
for which this was no longer true. 

Nick 
[email protected] 

[email protected]
 
> for (i=1;i<=2;i++)
> 
> Is there a difference with :
> for (i=1;i<=2;++i)
> 
> It is not clear with (about the
> preseance of incrementing : before or after)?

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index