empty <- function() length(l) == 0
push <- function(x) 
{
   l <<- c(l, list(x))
   print(l)
   invisible()
}
pop <- function() 
{
   if(empty()) stop("can't pop from an empty list")
   l[[1]] <<- NULL
   print(l)
   invisible()
}
l <- list() 
empty()

push(3)


push("abc")




push(matrix(1:6, nrow=2))








empty()

pop()




pop()


pop()

pop()