April 2017
Intermediate to advanced
316 pages
9h 33m
English
A stack is a collection that is based on the Last In First Out (LIFO) policy.
The following figure presents a sample stack:

To implement a simple functional stack, we need to provide push, pop, isEmpty, and size operations. We implemented a functional LinkedList in the previous section, which can be used to implement a simple functional stack with the following operations:
As seen here, the only operation that is missing is pop. Let's implement that:
func pop() -> (element: Element, list: Stack)? { switch ...Read now
Unlock full access