File utils/tableutil.lua

Functions

tableutil.clone (table) Performs a deep/recursive clone on the given table.
tableutil.equals (a, b) Tests the two given tables for equality.
tableutil.keys (...) Returns a (unique) list with all keys of all tables.
tableutil.merge (...) Merges the given tables into one instance.
tableutil.reduce2d (table, is_empty) Removes empty rows and columns at the beginning and the end of teh given 2D table.
tableutil.swapped_reindex2d (data, new_x, new_y) Reindexes the given 2d array/table, swapping the two dimensions.
tableutil.swapped_reindex3d (data, new_x, new_y, new_z) Reindexes the given 3d array/table, swapping the two dimensions.
tableutil.to_string (table, indent) Returns the string representation of the given table.


Functions

tableutil.clone (table)
Performs a deep/recursive clone on the given table.

Parameters

  • table: The table to deep clone.

Return value:

The clone of the table.
tableutil.equals (a, b)
Tests the two given tables for equality.

Parameters

  • a: The first table.
  • b: The second table.
tableutil.keys (...)
Returns a (unique) list with all keys of all tables.

Parameters

  • ...: The list of tables.

Return value:

A list with all keys.
tableutil.merge (...)
Merges the given tables into one instance. Note that no cloning is performed so fields may refer to the same instances.

Parameters

  • ...: The tables to merge.

Return value:

The merged table.
tableutil.reduce2d (table, is_empty)
Removes empty rows and columns at the beginning and the end of teh given 2D table.

Parameters

  • table: The 2D table.
  • is_empty: Optional. The function used for determining if the item is empty. By default nil and an empty string is considered empty. Expected is a function that takes one item and returns a boolean.
tableutil.swapped_reindex2d (data, new_x, new_y)
Reindexes the given 2d array/table, swapping the two dimensions.

Parameters

  • data: The array/table to reindex.
  • new_x: The new startpoint for the first dimension.
  • new_y: The new startpoint for the second dimension.

Return value:

The reindexed data.
tableutil.swapped_reindex3d (data, new_x, new_y, new_z)
Reindexes the given 3d array/table, swapping the two dimensions.

Parameters

  • data: The array/table to reindex.
  • new_x: The new startpoint for the first dimension.
  • new_y: The new startpoint for the second dimension.
  • new_z: The new startpoint for the third dimension.

Return value:

The reindexed data.
tableutil.to_string (table, indent)
Returns the string representation of the given table.

Parameters

  • table: The table.
  • indent: Optional. The number of spaces of indentation.

Return value:

The string representation of the given table.

Valid XHTML 1.0!