Linked lists
A linked list is a type of data structure. Because tables are dynamic entities, it is easy to implement linked lists in Lua. Each node is represented by a table and links are simply table fields that contain references to other tables.
Types of Lists
Basic Singly Linked
Here's a basic linked list. Each node has two fields, next (table) and value (string).
Circularly Linked
The circularly linked list is almost identical to the singly linked list, except you include a link from the last node to the first one. Be careful though, as it is possible to accidentally try to traverse it forever once inside a loop.
Here's a circularly linked list. It's slightly more complicated.
Doubly Linked List
Here's a doubly linked list. It is significantly more complicated than the singly linked list.
Even More Lists
It is possible to create many other types of linked lists to suit your needs. However, usually linked lists are not the most efficient data structure. Check the See Also section for other data structures.