Module table

Functions

clone (t, nometa) Make a shallow copy of a table, including any metatable (for a deep copy, use tree.clone).
clone_rename (map, t) Clone a table, renaming some keys.
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 one table into another.
new (x, t) Make a table with a default value for unset keys.
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
clone_rename (map, t)
Clone a table, renaming some keys.

Parameters

  • map: table {old_key=new_key, ...}
  • t: table to copy

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 one table into another. u is merged into t.

Parameters

  • t: first table
  • u: second table

Return value:

first 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
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!