Module table

Functions

clone (t, nometa) Make a shallow copy of a table, including any metatable (for a deep copy, use tree.clone).
empty (t) Return whether table is empty.
indices (t) Make the list of indices of a table.
invert (t) Invert a table.
merge (t, u) Merge two tables.
new (x, t) Make a table with a default value for unset keys.
rearrange (m, t) Rearrange some indices of a table.
size (t) Find the number of elements in a table.
sort (t, c) Make table.sort return its result.
values (t) Make the list of values of a table.


Functions

clone (t, nometa)
Make a shallow copy of a table, including any metatable (for a deep copy, use tree.clone).

Parameters

  • t: table
  • nometa: if non-nil don't copy metatable

Return value:

copy of table
empty (t)
Return whether table is empty.

Parameters

  • t: table

Return value:

true if empty or false otherwise
indices (t)
Make the list of indices of a table.

Parameters

  • t: table

Return value:

list of indices
invert (t)
Invert a table.

Parameters

  • t: table {i=v, ...}

Return value:

inverted table {v=i, ...}
merge (t, u)
Merge two tables. If there are duplicate fields, u's will be used. The metatable of the returned table is that of t.

Parameters

  • t: first table
  • u: second table

Return value:

merged table
new (x, t)
Make a table with a default value for unset keys.

Parameters

  • x: default entry value (default: nil)
  • t: initial table (default: {})

Return value:

table whose unset elements are x
rearrange (m, t)
Rearrange some indices of a table.

Parameters

  • m: table {old_index=new_index, ...}
  • t: table to rearrange

Return value:

rearranged table
size (t)
Find the number of elements in a table.

Parameters

  • t: table

Return value:

number of elements in t
sort (t, c)
Make table.sort return its result.

Parameters

  • t: table
  • c: comparator function

Return value:

sorted table
values (t)
Make the list of values of a table.

Parameters

  • t: table

Return value:

list of values

Valid XHTML 1.0!