I have a table of strings. I’d like an easy way to remove all of the duplicates of the table.
So if the table is {a, b, c, c, d, e, e} , after this operation it would be {a, b, c, d, e}
Alternatively, and probably preferably, is there a way to add an element to a table, but only if it is not already contained within the table.
<\noobquestion>
What I normally do for this is index the table on the string so for example
etc.
When you add a string you simply use the lines above and duplicates will be taken care of. You can then use a for … pairs do loop to read the data.
If you want to count the number of occurrences
use something like
As the end of the addition cycle if you need to turn the table around you can simply use something like