Difference between revisions of "Loop.R"

From Organic Design wiki
(0 -> 6)
(comment)
Line 1: Line 1:
 
# ==============================================================================
 
# ==============================================================================
# Loop evaluation e.g. 8 parts, 5 comparisons
+
# Loop evaluation e.g. 6 parts, 4 comparisons
 +
# this function is construting an array e.g. 1,2,3,4,5,6,1,2,3
 +
# and then subsetting sequential arrays of length four from it
 +
# e.g. 1,2,3,4 2,3,4,5 3,4,5,6 etc
 
# ==============================================================================
 
# ==============================================================================
  
Line 7: Line 10:
 
loop    <- 6
 
loop    <- 6
 
comp    <- 4
 
comp    <- 4
# seq makes a sequence from 1 to 8+5-1
 
# %% yields the modulus remainder of a division
 
 
loops <- 0:(loop+comp-1) %% loop +1  
 
loops <- 0:(loop+comp-1) %% loop +1  
  

Revision as of 03:47, 12 December 2005

  1. ==============================================================================
  2. Loop evaluation e.g. 6 parts, 4 comparisons
  3. this function is construting an array e.g. 1,2,3,4,5,6,1,2,3
  4. and then subsetting sequential arrays of length four from it
  5. e.g. 1,2,3,4 2,3,4,5 3,4,5,6 etc
  6. ==============================================================================


start <- 1 loop <- 6 comp <- 4 loops <- 0:(loop+comp-1) %% loop +1

for(i in seq(loop)){

 print(loops[seq(from=i, length=comp)])

}