% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/makeStack.R
\name{makeStack}
\alias{makeStack}
\title{Preparation of Stack}
\usage{
makeStack()
}
\value{
A list of functions \cr
  \code{push, pop,  inspect,  length} and \code{clear}
}
\description{
Preparation of Stack
}
\details{
This is a function  factory which makes  the following list of functions.\cr
  \code{push, pop,  inspect,  length} and \code{clear}

In the usual image of a stack, the newest object will be placed
on top of the older objects.
However, in this R version, the newest object will be placed
at the end of a hidden list named \code{valueList} in the function factory
environment.

It enables LIFO (Last-In First-Out) or  FILO (First-In Last-Out).
}
\examples{
 # generate functions
 stack <- makeStack()

 stack$push(3)
 stack$push(5)
 stack$push(9)
 stack$length()
 stack$inspect(1:stack$length())
 stack$pop()
 stack$inspect(1:stack$length())
 stack$pop()
 stack$inspect(1:stack$length())
 stack$pop()

 # Below causes error.
 # stack$inspect(1:stack$length())


 STACK=makeStack()
 PUSH <- STACK$push
 POP <- STACK$pop
 LEN <- STACK$length
 INSP <- STACK$inspect
 CLEAR <- STACK$clear
 PUSH( list(a=1,b=2,c="C"))
 PUSH( list(a=12,b=22,c="C2"))
 PUSH( list(a=13,b=23,c="C3"))
 INSP(1:LEN())
 POP()
 INSP(1:LEN())
 POP()
 INSP(1:LEN())


}
\references{
The original version is from the answer by Matt: \cr
  https://stackoverflow.com/questions/28687806
  /a-better-way-to-push-and-pop-to-from-lists-in-r
}
