Utilities

Functions on tables

halmd.utility.empty(t)

Test if table is empty.

halmd.utility.keys(t)

Returns table with sorted keys of table t as values.

halmd.utility.sorted(t)

Returns iterator over pairs of table t sorted by key.

halmd.utility.reverse(t)

Returns table with keys as values and values as keys.

Assertions

halmd.utility.assert_kwarg(args, key, level)

Assert keyword argument of table and return its value.

Parameters:
  • args (table) – argument table
  • key (string) – parameter key
  • level (number) – call stack level for error message (default: 2)
Returns:

args[key]

halmd.utility.assert_type(var, name, level)

Assert type of variable.

Parameters:
  • var – variable to check
  • name (string) – Lua type name
  • level (number) – call stack level for error message (default: 2)
Returns:

var