Module tree

Tables as trees.

Functions

clone (t, nometa) Make a deep copy of a tree, including any metatables
metatable.__index (tr, i) Tree __index metamethod.
metatable.__newindex (tr, i, v) Tree __newindex metamethod.
new (t) Make a table into a tree


Functions

clone (t, nometa)
Make a deep copy of a tree, including any metatables

Parameters

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

Return value:

copy of table
metatable.__index (tr, i)
Tree __index metamethod.

Parameters

  • tr: tree
  • i: non-table, or list of indices {i1 ... in}

Return value:

tr[i]...[in] if i is a table, or tr[i] otherwise
metatable.__newindex (tr, i, v)
Tree __newindex metamethod. Sets tr[i1]...[in] = v if i is a table, or tr[i] = v otherwise

Parameters

  • tr: tree
  • i: non-table, or list of indices {i1 ... in}
  • v: value
new (t)
Make a table into a tree

Parameters

  • t: table

Return value:

tree

Valid XHTML 1.0!