Module utable

Table manipulation functions to complement AwesomeWM's gears.table.

Info:

  • Copyright: 2019 James Reed
  • Author: James Reed <jcrd@tuta.io>

Functions

group (func, tbl) Group items in a table into lists according to the key returned by func.
filter (func, tbl) Get a new table containing the items in tbl that pass the filter function.
contains (a, b) Check if table a contains table b.
equal (a, b) Check if table a and table b contain the same items.
split (tbl, after) Split a table into left and right segments.
remove_item (tbl, item) Remove an item from a table.
remove (a, b) Remove items from table b that are found in table a.
add (a, b) Add items in table a to table b if they are not present.
reduce (func, tbl) Apply a reducer function to a table.


Functions

group (func, tbl)
Group items in a table into lists according to the key returned by func. func is given the current table value and must return the list key.

Parameters:

  • func The function.
  • tbl The table.

Returns:

    The new table.
filter (func, tbl)
Get a new table containing the items in tbl that pass the filter function.

Parameters:

  • func The filter function.
  • tbl The table.

Returns:

    The new table.
contains (a, b)
Check if table a contains table b.

Parameters:

  • a Haystack table.
  • b Needle table.

Returns:

    True if a contains b, otherwise false.
equal (a, b)
Check if table a and table b contain the same items.

Parameters:

  • a First table.
  • b Second table.

Returns:

    True if a and b are contain the same items, otherwise false.
split (tbl, after)
Split a table into left and right segments.

Parameters:

  • tbl The table.
  • after The index after which to split.

Returns:

    A table containing keys "l" and "r".
remove_item (tbl, item)
Remove an item from a table.

Parameters:

  • tbl The table.
  • item The item.

Returns:

    The new table.
remove (a, b)
Remove items from table b that are found in table a.

Parameters:

  • a Table of values to be removed.
  • b Removal table.

Returns:

    The new table.
add (a, b)
Add items in table a to table b if they are not present.

Parameters:

  • a Mixin table.
  • b Container table.

Returns:

    The new table.
reduce (func, tbl)
Apply a reducer function to a table. The reducer function is given two arguments: the accumulated value and the current table value. It must return the new accumulated value.

Parameters:

  • func The reducer function.
  • tbl The table.

Returns:

    The final accumulated value.
generated by LDoc 1.4.6 Last updated 2019-08-22 12:09:17