<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://ase.exopla.net/index.php?action=history&amp;feed=atom&amp;title=Module%3ATableTools%2Fdoc</id>
	<title>Module:TableTools/doc - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://ase.exopla.net/index.php?action=history&amp;feed=atom&amp;title=Module%3ATableTools%2Fdoc"/>
	<link rel="alternate" type="text/html" href="https://ase.exopla.net/index.php?title=Module:TableTools/doc&amp;action=history"/>
	<updated>2026-04-18T08:45:17Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.45.1</generator>
	<entry>
		<id>https://ase.exopla.net/index.php?title=Module:TableTools/doc&amp;diff=5068&amp;oldid=prev</id>
		<title>Sushoff: Created page with &quot;{{used in system}} {{module rating|p}} {{cascade-protected template|page=module}} {{lua|Module:Exponential search|noprotcat=yes}} This module includes a number of functions 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.  == Loading the module ==  To use any of the functions, first you must load the module.  &lt;syntaxhighlight lang=&quot;lua&quot;&gt; local TableTools = require(&#039;Module:TableToo...&quot;</title>
		<link rel="alternate" type="text/html" href="https://ase.exopla.net/index.php?title=Module:TableTools/doc&amp;diff=5068&amp;oldid=prev"/>
		<updated>2025-02-01T13:36:13Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;{{used in system}} {{module rating|p}} {{cascade-protected template|page=module}} {{lua|Module:Exponential search|noprotcat=yes}} This module includes a number of functions 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.  == Loading the module ==  To use any of the functions, first you must load the module.  &amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt; local TableTools = require(&amp;#039;Module:TableToo...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{used in system}}&lt;br /&gt;
{{module rating|p}}&lt;br /&gt;
{{cascade-protected template|page=module}}&lt;br /&gt;
{{lua|Module:Exponential search|noprotcat=yes}}&lt;br /&gt;
This module includes a number of functions 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.&lt;br /&gt;
&lt;br /&gt;
== Loading the module ==&lt;br /&gt;
&lt;br /&gt;
To use any of the functions, first you must load the module.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local TableTools = require(&amp;#039;Module:TableTools&amp;#039;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== isPositiveInteger ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
TableTools.isPositiveInteger(value)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Returns &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt; if &amp;lt;code&amp;gt;&amp;#039;&amp;#039;value&amp;#039;&amp;#039;&amp;lt;/code&amp;gt; is a positive integer, and &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt; if not. Although it doesn&amp;#039;t operate on tables, it is included here as it is useful for determining whether a given table key is in the array part or the hash part of a table.&lt;br /&gt;
&lt;br /&gt;
== isNan ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
TableTools.isNan(value)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Returns &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt; if &amp;lt;code&amp;gt;&amp;#039;&amp;#039;value&amp;#039;&amp;#039;&amp;lt;/code&amp;gt; is a [[NaN]] value, and &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt; if not. Although it doesn&amp;#039;t operate on tables, it is included here as it is useful for determining whether a value can be a valid table key. (Lua will generate an error if a NaN value is used as a table key.)&lt;br /&gt;
&lt;br /&gt;
== shallowClone ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
TableTools.shallowClone(t)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Returns a clone of a table. The value returned is a new table, but all subtables and functions are shared. Metamethods are respected, but the returned table will have no metatable of its own. If you want to make a new table with no shared subtables and with metatables transferred, you can use &amp;lt;code&amp;gt;[[mw:Extension:Scribunto/Lua reference manual#mw.clone|mw.clone]]&amp;lt;/code&amp;gt; instead. If you want to make a new table with no shared subtables and without metatables transferred, use &amp;lt;code&amp;gt;[[#deepCopy|deepCopy]]&amp;lt;/code&amp;gt; with the &amp;lt;code&amp;gt;noMetatable&amp;lt;/code&amp;gt; option.&lt;br /&gt;
&lt;br /&gt;
== removeDuplicates ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
TableTools.removeDuplicates(t)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Removes duplicate values from an array. This function is only designed to work with standard arrays: keys that are not positive integers are ignored, as are all values after the first &amp;lt;code&amp;gt;nil&amp;lt;/code&amp;gt; value. (For arrays containing &amp;lt;code&amp;gt;nil&amp;lt;/code&amp;gt; values, you can use &amp;lt;code&amp;gt;[[#compressSparseArray|compressSparseArray]]&amp;lt;/code&amp;gt; first.) The function tries to preserve the order of the array: the earliest non-unique value is kept, and all subsequent duplicate values are removed. For example, for the table {{code|code={5, 4, 4, 3, 4, 2, 2, 1}|lang=lua}} &amp;lt;code&amp;gt;removeDuplicates&amp;lt;/code&amp;gt; will return {{code|code={5, 4, 3, 2, 1}|lang=lua}}.&lt;br /&gt;
&lt;br /&gt;
== numKeys ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
TableTools.numKeys(t)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Takes a table &amp;lt;code&amp;gt;&amp;#039;&amp;#039;t&amp;#039;&amp;#039;&amp;lt;/code&amp;gt; and returns an array containing the numbers of any positive integer keys that have non-nil values, sorted in numerical order. For example, for the table {{code|code={&amp;#039;foo&amp;#039;, nil, &amp;#039;bar&amp;#039;, &amp;#039;baz&amp;#039;, a = &amp;#039;b&amp;#039;}|lang=lua}}, &amp;lt;code&amp;gt;numKeys&amp;lt;/code&amp;gt; will return {{code|code={1, 3, 4}|lang=lua}}.&lt;br /&gt;
&lt;br /&gt;
== affixNums ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
TableTools.affixNums(t, prefix, suffix)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Takes a table &amp;lt;code&amp;gt;&amp;#039;&amp;#039;t&amp;#039;&amp;#039;&amp;lt;/code&amp;gt; and returns an array containing the numbers of keys with the optional prefix &amp;lt;code&amp;gt;&amp;#039;&amp;#039;prefix&amp;#039;&amp;#039;&amp;lt;/code&amp;gt; and the optional suffix &amp;lt;code&amp;gt;&amp;#039;&amp;#039;suffix&amp;#039;&amp;#039;&amp;lt;/code&amp;gt;. For example, for the table {{code|code={a1 = &amp;#039;foo&amp;#039;, a3 = &amp;#039;bar&amp;#039;, a6 = &amp;#039;baz&amp;#039;}|lang=lua}} and the prefix &amp;lt;code&amp;gt;&amp;#039;a&amp;#039;&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;affixNums&amp;lt;/code&amp;gt; will return {{code|code={1, 3, 6}|lang=lua}}. All characters in &amp;lt;code&amp;gt;&amp;#039;&amp;#039;prefix&amp;#039;&amp;#039;&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;&amp;#039;&amp;#039;suffix&amp;#039;&amp;#039;&amp;lt;/code&amp;gt; are interpreted literally.&lt;br /&gt;
&lt;br /&gt;
== numData ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
TableTools.numData(t, compress)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Given a table with keys like &amp;lt;code&amp;gt;&amp;quot;foo1&amp;quot;&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;&amp;quot;bar1&amp;quot;&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;&amp;quot;foo2&amp;quot;&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;&amp;quot;baz2&amp;quot;&amp;lt;/code&amp;gt;, returns a table of subtables in the format {{code|code={ [1] = {foo = &amp;#039;text&amp;#039;, bar = &amp;#039;text&amp;#039;}, [2] = {foo = &amp;#039;text&amp;#039;, baz = &amp;#039;text&amp;#039;} }|lang=lua}}. Keys that don&amp;#039;t end with an integer are stored in a subtable named &amp;lt;code&amp;gt;&amp;quot;other&amp;quot;&amp;lt;/code&amp;gt;. The compress option compresses the table so that it can be iterated over with &amp;lt;code&amp;gt;ipairs&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== compressSparseArray ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
TableTools.compressSparseArray(t)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Takes an array &amp;lt;code&amp;gt;&amp;#039;&amp;#039;t&amp;#039;&amp;#039;&amp;lt;/code&amp;gt; with one or more nil values, and removes the nil values while preserving the order, so that the array can be safely traversed with &amp;lt;code&amp;gt;ipairs&amp;lt;/code&amp;gt;. Any keys that are not positive integers are removed. For example, for the table {{code|code={1, nil, foo = &amp;#039;bar&amp;#039;, 3, 2}|lang=lua}}, &amp;lt;code&amp;gt;compressSparseArray&amp;lt;/code&amp;gt; will return {{code|code={1, 3, 2}|lang=lua}}.&lt;br /&gt;
&lt;br /&gt;
== sparseIpairs ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
TableTools.sparseIpairs(t)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is an iterator function for traversing a sparse array &amp;lt;code&amp;gt;&amp;#039;&amp;#039;t&amp;#039;&amp;#039;&amp;lt;/code&amp;gt;. It is similar to &amp;lt;code&amp;gt;[[mw:Extension:Scribunto/Lua reference manual#ipairs|ipairs]]&amp;lt;/code&amp;gt;, but will continue to iterate until the highest numerical key, whereas &amp;lt;code&amp;gt;ipairs&amp;lt;/code&amp;gt; may stop after the first &amp;lt;code&amp;gt;nil&amp;lt;/code&amp;gt; value. Any keys that are not positive integers are ignored.&lt;br /&gt;
&lt;br /&gt;
Usually &amp;lt;code&amp;gt;sparseIpairs&amp;lt;/code&amp;gt; is used in a generic &amp;lt;code&amp;gt;for&amp;lt;/code&amp;gt; loop.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
for i, v in TableTools.sparseIpairs(t) do&lt;br /&gt;
   -- code block&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that &amp;lt;code&amp;gt;sparseIpairs&amp;lt;/code&amp;gt; uses the &amp;lt;code&amp;gt;[[mw:Extension:Scribunto/Lua reference manual#pairs|pairs]]&amp;lt;/code&amp;gt; function in its implementation. Although some table keys appear to be ignored, all table keys are accessed when it is run.&lt;br /&gt;
&lt;br /&gt;
== size ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
TableTools.size(t)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finds the size of a key/value pair table ([[associative array]]). For example, for {{code|code={foo = &amp;#039;foo&amp;#039;, bar = &amp;#039;bar&amp;#039;}|lang=lua}}, &amp;lt;code&amp;gt;size&amp;lt;/code&amp;gt; will return &amp;lt;code&amp;gt;2&amp;lt;/code&amp;gt;. The function will also work on arrays, but for arrays it is more efficient to use the &amp;lt;code&amp;gt;#&amp;lt;/code&amp;gt; operator. Note that to find the size, this function uses the &amp;lt;code&amp;gt;[[mw:Extension:Scribunto/Lua reference manual#pairs|pairs]]&amp;lt;/code&amp;gt; function to iterate through all of the keys.&lt;br /&gt;
&lt;br /&gt;
== keysToList ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
TableTools.keysToList(t, keySort, checked)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Returns a list of the keys in a table, sorted using either a default comparison function or a custom &amp;lt;code&amp;gt;&amp;#039;&amp;#039;keySort&amp;#039;&amp;#039;&amp;lt;/code&amp;gt; function, which follows the same rules as the &amp;lt;code&amp;gt;comp&amp;lt;/code&amp;gt; function supplied to &amp;lt;code&amp;gt;[[mw:Extension:Scribunto/Lua reference manual#table.sort|table.sort]]&amp;lt;/code&amp;gt;. If &amp;lt;code&amp;gt;&amp;#039;&amp;#039;keySort&amp;#039;&amp;#039;&amp;lt;/code&amp;gt; is &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt;, no sorting is done. Set &amp;lt;code&amp;gt;&amp;#039;&amp;#039;checked&amp;#039;&amp;#039;&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt; to skip the internal type checking.&lt;br /&gt;
&lt;br /&gt;
== sortedPairs ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
TableTools.sortedPairs(t, keySort)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Iterates through a table, with the keys sorted using the &amp;lt;code&amp;gt;keysToList&amp;lt;/code&amp;gt; function. If there are only numerical keys, &amp;lt;code&amp;gt;sparseIpairs&amp;lt;/code&amp;gt; is probably more efficient.&lt;br /&gt;
&lt;br /&gt;
== isArray ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
TableTools.isArray(value)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Returns &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt; if &amp;lt;code&amp;gt;&amp;#039;&amp;#039;value&amp;#039;&amp;#039;&amp;lt;/code&amp;gt; is a table and all keys are consecutive integers starting at 1.&lt;br /&gt;
&lt;br /&gt;
== isArrayLike ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
TableTools.isArrayLike(value)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Returns &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt; if &amp;lt;code&amp;gt;&amp;#039;&amp;#039;value&amp;#039;&amp;#039;&amp;lt;/code&amp;gt; is iterable and all keys are consecutive integers starting at 1.&lt;br /&gt;
&lt;br /&gt;
== invert ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
TableTools.invert(arr)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Transposes the keys and values in an array. For example, {{code|invert{ &amp;quot;a&amp;quot;, &amp;quot;b&amp;quot;, &amp;quot;c&amp;quot; }|lua}} yields {{code|code={ a=1, b=2, c=3 }|lang=lua}}.&lt;br /&gt;
&lt;br /&gt;
== listToSet ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
TableTools.listToSet(arr)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Creates a set from the array part of the table &amp;lt;code&amp;gt;&amp;#039;&amp;#039;arr&amp;#039;&amp;#039;&amp;lt;/code&amp;gt;. Indexing the set by any of the values of the array returns &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt;. For example, {{code|listToSet{ &amp;quot;a&amp;quot;, &amp;quot;b&amp;quot;, &amp;quot;c&amp;quot; }|lua}} yields {{code|code={ a=true, b=true, c=true }|lang=lua}}.&lt;br /&gt;
&lt;br /&gt;
== deepCopy ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
TableTools.deepCopy(orig, noMetatable, alreadySeen)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Creates a copy of the table &amp;lt;code&amp;gt;&amp;#039;&amp;#039;orig&amp;#039;&amp;#039;&amp;lt;/code&amp;gt;. As with &amp;lt;code&amp;gt;mw.clone&amp;lt;/code&amp;gt;, all values that are not functions are duplicated and the identity of tables is preserved. If &amp;lt;code&amp;gt;&amp;#039;&amp;#039;noMetatable&amp;#039;&amp;#039;&amp;lt;/code&amp;gt; is &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt;, then the metatable (if any) is not copied. Can copy tables loaded with &amp;lt;code&amp;gt;mw.loadData&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Similar to &amp;lt;code&amp;gt;mw.clone&amp;lt;/code&amp;gt;, but &amp;lt;code&amp;gt;mw.clone&amp;lt;/code&amp;gt; cannot copy tables loaded with &amp;lt;code&amp;gt;mw.loadData&amp;lt;/code&amp;gt; and does not allow metatables &amp;lt;em&amp;gt;not&amp;lt;/em&amp;gt; to be copied.&lt;br /&gt;
&lt;br /&gt;
== sparseConcat ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
TableTools.sparseConcat(t, sep, i, j)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Concatenates all values in the table that are indexed by a positive integer, in order. For example, {{code|sparseConcat{ &amp;quot;a&amp;quot;, nil, &amp;quot;c&amp;quot;, &amp;quot;d&amp;quot; }|lua}} yields {{code|&amp;quot;acd&amp;quot;|lua}} and {{code|sparseConcat{ nil, &amp;quot;b&amp;quot;, &amp;quot;c&amp;quot;, &amp;quot;d&amp;quot; }|lua}} yields {{code|&amp;quot;bcd&amp;quot;|lua}}.&lt;br /&gt;
&lt;br /&gt;
== length ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
TableTools.length(t, prefix)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finds the length of an array or of a quasi-array with keys with an optional &amp;lt;code&amp;gt;&amp;#039;&amp;#039;prefix&amp;#039;&amp;#039;&amp;lt;/code&amp;gt; such as &amp;quot;data1&amp;quot;, &amp;quot;data2&amp;quot;, etc. It uses an [[exponential search]] algorithm to find the length, so as to use as few table lookups as possible.&lt;br /&gt;
&lt;br /&gt;
This algorithm is useful for arrays that use metatables (e.g. [[mw:Extension:Scribunto/Lua reference manual#frame.args|frame.args]]) and for quasi-arrays. For normal arrays, just use the [[mw:Extension:Scribunto/Lua reference manual#Length operator|# operator]], as it is implemented in [[C (programming language)|C]] and will be quicker.&lt;br /&gt;
&lt;br /&gt;
== inArray ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;TableTools.inArray(array, searchElement)&lt;br /&gt;
TableTools.inArray(array, searchElement, fromIndex)&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Returns &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt; if &amp;lt;code&amp;gt;&amp;#039;&amp;#039;searchElement&amp;#039;&amp;#039;&amp;lt;/code&amp;gt; is a member of the array &amp;lt;code&amp;gt;&amp;#039;&amp;#039;array&amp;#039;&amp;#039;&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt; otherwise. Equivalent to the javascript [https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/includes Array.prototype.includes()] function, except fromIndex is 1-indexed instead of zero-indexed.&lt;br /&gt;
&lt;br /&gt;
=== fromIndex ===&lt;br /&gt;
&amp;lt;code&amp;gt;fromIndex&amp;lt;/code&amp;gt; is the optional 1-based index at which to start searching. If &amp;lt;code&amp;gt;fromIndex&amp;lt;/code&amp;gt; is not present, all values in the array will be searched and the array will be treated as a table/[[associative array]] (it will be iterated over using &amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot; inline&amp;gt;pairs()&amp;lt;/syntaxhighlight&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
If &amp;lt;code&amp;gt;fromIndex&amp;lt;/code&amp;gt; is present and an integer, the array is assumed to be a conventional array/sequence/list (indexed with consecutive integer keys starting at &amp;lt;code&amp;gt;1&amp;lt;/code&amp;gt;, and interated over using &amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot; inline&amp;gt;ipairs()&amp;lt;/syntaxhighlight&amp;gt;). Only the values whose index is &amp;lt;code&amp;gt;fromIndex&amp;lt;/code&amp;gt; or higher will be searched.&lt;br /&gt;
&lt;br /&gt;
In the following examples, &amp;lt;code&amp;gt;#array&amp;lt;/code&amp;gt; represents the length of the integer-keyed portion of the array.&lt;br /&gt;
&lt;br /&gt;
* If &amp;lt;code&amp;gt;fromIndex &amp;lt; 0&amp;lt;/code&amp;gt; it will count back from the end of the array, e.g. a value of &amp;lt;code&amp;gt;-1&amp;lt;/code&amp;gt; will only search the last integer-keyed element in the array. If &amp;lt;code&amp;gt;fromIndex &amp;lt;= (-1 * #array)&amp;lt;/code&amp;gt;, the entire integer-keyed portion of the array will be searched.&lt;br /&gt;
* If &amp;lt;code&amp;gt;fromIndex = 0&amp;lt;/code&amp;gt; it will be treated as a &amp;lt;code&amp;gt;1&amp;lt;/code&amp;gt; and the entire integer-keyed portion of the array will be searched.&lt;br /&gt;
* If &amp;lt;code&amp;gt;fromIndex &amp;gt; #array&amp;lt;/code&amp;gt;, the array is not searched and &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt; is returned.&lt;br /&gt;
&lt;br /&gt;
== merge ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
TableTools.merge(...)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Given the arrays, returns an array containing the elements of each input array in sequence.&lt;br /&gt;
&lt;br /&gt;
== extend ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
TableTools.extend(arr1, arr2)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Extends the first array in place by appending all elements from the second array.&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* {{ml|params|}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;includeonly&amp;gt;{{Sandbox other||&lt;br /&gt;
[[Category:Lua metamodules|TableTools]]&lt;br /&gt;
}}&amp;lt;/includeonly&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sushoff</name></author>
	</entry>
</feed>