A List as a Stack

Until now lists (and arrays) have been presented as linear arrays of data with indexes identifying each element:

Use your imagination for a moment and imagine the array elements as a vertical stack:

In computer terminology, this list is called a stack. Stacks are useful for accumulating tasks that you want processed in order. A good example is a game of Klondike Solitaire. Each of the seven piles of cards represents a stack. Initially, cards are placed onto the stack face down. As they are needed, they are turned over and ...

Get Sams Teach Yourself Perl in 24 Hours now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.