Learn R Programming

rmngb (version 0.6-1)

Stack: Stack Operations

Description

Methods to create and interact with stacks.

Usage

createStack(...) push(stack, x) pop(stack) "print"(x, ...) "as.list"(x, ...) "length"(x)

Arguments

...
one or more objects to be put into a stack.
stack
a stack object as created by createStack.
x
an object to push on a stack.

Value

For createStack an object of class stack. No value for push, the first object in the stack for pop.

Details

The objects in ... will be ordered in the stack in the order they appear, with the first at the top.

See Also

list.

Examples

Run this code
stack <- createStack(rnorm(2), "some text")
stack
length(stack)
push(stack, 2)
stack
pop(stack)
stack

Run the code above in your browser using DataLab