Changes
		
		
		
		
		
		
		Jump to navigation
		Jump to search
		
		
		
		
		
		
		
		
	
add a fancy introductory comment
--[[--------------------------------------------------------------------------------------                               TableTools                                       ----                                                                                ---- This module includes a number of functions that can be useful when for dealing with Lua tables.       ---- It is a meta-module, meant to be called from other Lua modules, and should     ---- not be called directly from #invoke.                                           ----------------------------------------------------------------------------------------]]
local p = {}
--[[
------------------------------------------------------------------------------------
-- isPositiveInteger
--
-- useful for determining whether a given table key is in the array part or the
-- hash part of a table.
------------------------------------------------------------------------------------
--]]
function p.isPositiveInteger(num)
--[[
------------------------------------------------------------------------------------
-- getNumKeys
--
-- This takes a table and returns an array containing the numbers of any numerical
-- keys that have non-nil values, sorted in numerical order.
------------------------------------------------------------------------------------
--]]
function p.getNumKeys(t)
--[[
------------------------------------------------------------------------------------
-- getAffixNums
--
-- {a1 = 'foo', a3 = 'bar', a6 = 'baz'} and the prefix "a", getAffixNums will
-- return {1, 3, 6}.
------------------------------------------------------------------------------------
--]]
function p.getAffixNums(t, prefix, suffix)
--[[
------------------------------------------------------------------------------------
-- compressSparseArray
--
-- while preserving the order, so that the array can be safely traversed with
-- ipairs.
------------------------------------------------------------------------------------
--]]
function p.compressSparseArray(t)
--[[
------------------------------------------------------------------------------------
-- sparseIpairs
--
-- This is an iterator for sparse arrays. It can be used like ipairs, but can
-- handle nil values.
------------------------------------------------------------------------------------
--]]
function p.sparseIpairs(t)