# for, while, repeat
# examples
> x <- matrix(0, nrow=3, ncol=4)
> for(i in 1:3){ for(j in 1:4){ x[i,j]<-i+j } }
> while(x*2<10000){ x<-x*2; i<-i+1 }
> repeat{ i<-i+1; x<-x*2; if(x*2>10000) break }
> y <- NULL
> for(i in 1:3) { y<-y+i; cat('i is',i, '\n') }
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment