I have a table in lua
test = {1,2,4,2,3,4,2,3,4, "A", "B", "A"}
I want to delete all duplicate items in a table. The exit should be
test = {1,2,4,3, "A", "B"}
EDIT:
My attempt:
> items = {1,2,4,2,3,4,2,3,4, "A", "B", "A"}
> flags = {}
> for i = 1, table.getn (items) do
if not flags [items [i]] then
io.write ('' .. items [i])
flags [items [i]] = true
end
>> end
1 2 4 3 A B>
Now it works fine. Thanks for the answers and comments.
source share