Tables are a strong unifying data constructor. They directly implement a multitude of data types, like ordinary arrays, records, sets, bags, and lists.

Arrays need no explanations.
In Lua, it is conventional to start indices from 1,
but this is only a convention.
Arrays can be indexed by 0, negative numbers, or any other value (but ** nil** ).
Records are also trivially implemented by the syntactic sugar
` a.x`
.

The best way to implement a set is to store
its elements as indices of a table.
The statement ` s = {}`
creates an empty set

Bags can be implemented similarly to sets, but using the value associated to an element as its counter. So, to insert an element, the following code is enough:

and to remove an element:if s[x] then s[x] = s[x]+1 else s[x] = 1 end

if s[x] then s[x] = s[x]-1 end if s[x] == 0 then s[x] = nil end

Lisp-like lists also have an easy implementation.
The ``cons'' of two elements ` x`
and