#' Class Stack
#'
#' @param data
#'
#' @return
#' @export
#'
#' @examples
Stack <- function(data = NULL) {
# ver 3.0
nc = list(
data <- list(),
top <- function() {
return(data[length(data)])
},
pop <- function() {
d <- nc$top()
data[length(data)] <- NULL
return(d)
},
push <- function(e) {
data[length(data) + 1] <- e
},
empty <- function() {
data <- list()
},
isempty <- function() {
return(is.null(nc$data))
},
main = function(data) {
nc$data <- data
}
)
nc$main(data)
nc <- list2env(nc)
class(nc) <- "Config"
return(nc)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.