What are the Lua standard library table processing functions
This article mainly introduces "what are the Lua standard library table processing functions". In the daily operation, I believe that many people have doubts about the Lua standard library table processing functions. Xiaobian consulted all kinds of data and sorted out simple and easy-to-use operation methods. I hope it will be helpful for you to answer the doubts about "what are the Lua standard library table processing functions?" Next, please follow the editor to study!
The table processing library provides general table manipulation functions, and all operations are based on tables.
Note: all functions only apply to tables accessed with a digital index, with a 1-based index.
1. Table.concat (table [, sep [, I [, j])
Function: return to connect the strings in the table with sep. Sepis defaults to empty strings, I defaults to 1, j defaults to table length, and returns empty strings if I is greater than j
2. Table.insert (table, [pos,] value)
Function: pos inserts the value value at the specified index location, and moves the element after pos back. POS defaults to the length of the table plus 1 (that is, table.insert (tline x) adds x to the end of the table).
3. Table.maxn (table) table.getn (table)
Function: return table * an index value that is not nil
4. Table.remove (table [, pos])
Function: delete the value of the specified index location and move the value after the index forward. If it succeeds, it returns the value of the deleted index location; pos defaults to the length of the table (that is, deletes an element of the table by default)
5. Table.sort (table [, comp])
Function: sort the values in the table by the function provided by comp. The default comp is the Lua operator.