

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Exam; Professor: Matloff; Class: Scripting Languages; Subject: Engineering Computer Science; University: University of California - Davis; Term: Unknown 2009;
Typology: Exams
1 / 2
This page cannot be seen from the preview
Don't miss anything!


timeab <- function(a,b) return(_________________________________)
v10 <- function(indices,n) { v <- rep(0,n) v[indices] <- ______________________________ vo <- list(vec = v) class(vo) <- "v10" return(vo) }
getindices <- function(v) { return(____________________________________) }
print.v10 <- function(v) { print(___________________________________) }
"%-%" <- function(va,vb) { a <- getindices(va) b <- getindices(vb) i <- ___________________________________ return(__________________________________) }
> x <- v10(c(1,4),4) > y <- v10(c(3,4),4) > x [1] 1 4 > x$vec [1] 1 0 0 1 > getindices(x) [1] 1 4 > z <- x %-% y > z [1] 1 > z$vec [1] 1 0 0 0
> u <- c(3,4,5,5,12,13) > ____________(u,1) [1] 3 > ____________(u,5) [1] 12 > ____________(u,6) [1] 13
reduce <- function(f,v) { rslt <- _______________________ for (_____________________) _________________________ return(rslt) }
parfindfirst <- function(m,rowtot,cls,blksz) { for (i in 1:(nrow(m)/blksz)) { startrow <- 1 + (i-1) * blksz endrow <- i * blksz mblk <- m[startrow:endrow,,drop=F] rslt <- parApply(_________________________________________) rgt <- ________________________________________ if (any(rgt)) return(_______________________________________) } return(0) }
sim$evnts[sim$evnts[,1] >= a & sim$evnts[,1] <= b]
which(v$vec==1) getindices(v) setdiff(a,b) v10(i,length(va))
inf_vector <<- v
v[1] for (vi in v[-1]) rslt <- f(rslt,vi)
parfindfirst <- function(m,rowtot,cls,blksz) { for (i in 1:(nrow(m)/blksz)) { startrow <- 1 + (i-1) * blksz endrow <- i * blksz mblk <- m[startrow:endrow,,drop=F] rslt <- parApply(cls,mblk,1,sum)
rgt <- rslt >= rowtot if (any(rgt)) { return(startrow-1+which(rgt)[1]) } } return(0) }