stack creates a stack.

stack(items = NULL)

Arguments

items

a list of items

Details

Following methods are exposed:


.$push(item)
.$pop()
.$peek()
.$clear()
.$size()
.$as_list()
.$print()
  • item: any R object

See also

Examples

s <- stack()
s$push("first")
s$push("second")
s$pop()  # second
#> [1] "second"
s$pop()  # first
#> [1] "first"

s <- stack(list("foo", "bar"))
s$push("baz")$push("bla")