1. R uses column-major storage, while C/C++ uses row-major. So one version of a matrix will be the transpose of the other. 2. nextIter <- function(itrObj) { self <<- itrObj itrObj$nxt() } resetIter <- function(itrObj) { self <<- itrObj itrObj$rst() } # test example # create the iterator object q <- new.env() q$a <- c(5,12,13) q$i <- 0 q$nxt <- function() { self$i <- self$i + 1 self$a[self$i] } q$rst <- function() { self$i <- 0 } # try it print(nextIter(q)) # 5 print(nextIter(q)) # 12 print(nextIter(q)) # 13 resetIter(q) print(nextIter(q)) # 5 3. # run this ONCE setup <- function() { source('http://heather.cs.ucdavis.edu/~matloff/145/SuppMaterials/Walk.R') download.file('http://heather.cs.ucdavis.edu/testdir.zip','timp') unzip('timp') } findLtrFile <- function(startDir,startLtr) { walk(startDir,lookForLtr, list(startLtr=startLtr,found=FALSE,foundDir=NULL,foundFile=NULL)) } lookForLtr <- function(drname,filelist,arg) { if (arg$found) return(arg) for (fname in filelist) { if (substr(fname,1,1) == arg$startLtr) { arg$found <- TRUE arg$foundDir <- getwd() arg$foundFile <- fname return(arg) } } arg } setup() startDir <- getwd() findLtrFile(startDir, 'y')