DESCRIPTION Students: Please make sure to log in to OMSI using the address of the form ajones.bsmith@ucdavis.edu, concatenating the official UCD e-mail addresses as shown. QUESTION (30 pts) A difficulty discussed in class regarding interfacing R to C/C++ involved "backwards" (or "flipped") matrices. Explain. QUESTION -ext .R -run 'Rscript omsi_answer2.R' (35 pts) Here you will implement iterators in R. The basic object will be an R environment, consisting of functions nxt() (get next iterate) and rst() (reset counter) and whatever data items are needed. That function will have access to a variable named 'self', pointing to the object of which nxt() is a member, similar to C++/Java. An external function, nextIter(itrObj) will be called with the environment as argument, and similarly resetIter(itrObj) will reset the object. Note: You will need to use global variables. nextIter <- function(itrObj) { } resetIter <- function(itrObj) { } # test example # create the iterator object, just gets 'a' element by element 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 QUESTION -ext .R -run 'Rscript omsi_answer3.R' (35 pts) Here you will use the R walk() function presented in the supplement. The goal is to write a function findLtrFile() that finds SOME file (there could be more than 1) whose name begins with the specified letter. Once such a file is found, the directory and file name are returned, avoiding unnecessary further computation to the extent possible. # 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) { }