Learn R Programming

flifo (version 0.1.5)

push: Insert an object into a stack

Description

The push function inserts an object into .stack.

Usage

push(.stack, x)

Arguments

.stack

A stack.

x

An object to insert in .stack.

Value

NULL is returned invisibly.

Details

The push function is not pure. Side effects (made on purpose) are:

  • .stack is modified in the calling environment;

  • x is removed (deleted) if it exists in the calling environment.

See Also

pop.

Examples

Run this code
# NOT RUN {
(s <- lifo(max_length = 3)) # empty LIFO
(push(s, 0.3)) #
(push(s, data.frame(x=1:2, y=2:3))) 
obj <- pop(s) # get the last element inserted

# }

Run the code above in your browser using DataLab