table.clear(t) | Removes all values from the given table. |
table.copy(src, dest) | Copies the contents from one table to another. Overwrites existing elements in the destination table. Preserves table cycles |
table.count(haystack, needle) | Counts the number of elements in a table. Optionally counts the number of occurrences of a specific value. |
table.empty(t) | Checks if the given table is empty. |
table.find(haystack, needle, offset) | Finds the first occurrence of a given value in a table. |
table.random(t) | Returns a random element from a table. |
table.reverse(src, dest) | Reverses all of the elements in a table. |
table.rfind(haystack, needle, offset) | Finds the last occurrence of a given value in a table. |
table.shuffle(src, dest) | Randomly shuffles the elements in a table. |
table.unique(t) | Checks for duplicate elements in a table. |
table | t The table that will be cleared |
table | src Source table |
table | dest (optional) Destination table |
Returns | |
---|---|
table | Resulting table |
table | haystack The table that will be searched |
value | needle (optional) Search value |
Returns | |
---|---|
number | Number of occurrences (when the optional value is specified) |
number | Total number of elements |
table | t Table that will be checked |
Returns | |
---|---|
boolean | True if empty or false otherwise |
table | haystack Numerically-indexed table |
value | needle Search value |
number | offset (1) Starting index |
Returns | |
---|---|
number | Numeric index or nil |
table | t Numerically-indexed table |
Returns | |
---|---|
value | Random element |
number | Index of the random element |
table | src Numerically-indexed table |
table | dest (optional) Destination table |
Returns | |
---|---|
table | Reversed table |
table | haystack Numerically-indexed table |
value | needle Search value |
number | offset Starting index |
Returns | |
---|---|
number | Numeric index or nil |
table | src Numerically-indexed table |
table | dest (optional) Destination table |
Returns | |
---|---|
table | Shuffled table |
table | t The table that will be checked |
Returns | |
---|---|
boolean | True if all elements are unique |