x <- 1:5
(last <- ult(x))
(penultimate <- ult(x, 2)) # 2nd last.
# \dontshow{
stopifnot(last==5)
stopifnot(penultimate==4)
# }
(ult(x) <- 6)
(ult(x, 2) <- 7) # 2nd last.
x
# \dontshow{
stopifnot(all(x == c(1:3, 7L, 6L)))
# }
Run the code above in your browser using DataLab