<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.mkwtas.com/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://wiki.mkwtas.com/index.php?action=history&amp;feed=atom&amp;title=Module%3ATableTools%2Fdoc"/>
	<link rel="alternate" type="text/html" href="https://wiki.mkwtas.com/index.php?title=Module:TableTools/doc&amp;action=history"/>
	<updated>2026-04-10T09:11:49Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.5</generator>
	<entry>
		<id>https://wiki.mkwtas.com/index.php?title=Module:TableTools/doc&amp;diff=351&amp;oldid=prev</id>
		<title>Boumi: 1 revision imported: Module:TableTools</title>
		<link rel="alternate" type="text/html" href="https://wiki.mkwtas.com/index.php?title=Module:TableTools/doc&amp;diff=351&amp;oldid=prev"/>
		<updated>2023-01-26T18:54:27Z</updated>

		<summary type="html">&lt;p&gt;1 revision imported: Module:TableTools&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 20:54, 26 January 2023&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;en&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Boumi</name></author>
	</entry>
	<entry>
		<id>https://wiki.mkwtas.com/index.php?title=Module:TableTools/doc&amp;diff=350&amp;oldid=prev</id>
		<title>wikipedia&gt;Pppery: Suppress inapplicable tracking category</title>
		<link rel="alternate" type="text/html" href="https://wiki.mkwtas.com/index.php?title=Module:TableTools/doc&amp;diff=350&amp;oldid=prev"/>
		<updated>2022-02-21T01:32:01Z</updated>

		<summary type="html">&lt;p&gt;Suppress inapplicable tracking category&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|protected}}&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. For example, for the table {{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 table 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 table 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}}. See also [[Module:Lua set]] for more advanced ways to create a set.&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;&lt;br /&gt;
TableTools.inArray(arr, valueToFind)&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;valueToFind&amp;#039;&amp;#039;&amp;lt;/code&amp;gt; is a member of the array &amp;lt;code&amp;gt;&amp;#039;&amp;#039;arr&amp;#039;&amp;#039;&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt; otherwise.&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>wikipedia&gt;Pppery</name></author>
	</entry>
</feed>