<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.geministation.com/index.php?action=history&amp;feed=atom&amp;title=Module%3AEnum%2Fdoc</id>
	<title>Module:Enum/doc - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.geministation.com/index.php?action=history&amp;feed=atom&amp;title=Module%3AEnum%2Fdoc"/>
	<link rel="alternate" type="text/html" href="https://wiki.geministation.com/index.php?title=Module:Enum/doc&amp;action=history"/>
	<updated>2026-06-04T08:33:34Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.8</generator>
	<entry>
		<id>https://wiki.geministation.com/index.php?title=Module:Enum/doc&amp;diff=8876&amp;oldid=prev</id>
		<title>Banri: Created page with &quot;{{Documentation}} {{Helper module |name = Enum  |fname1 = &lt;nowiki&gt;all(&amp;nbsp;enum, [fn], [clone|false]&amp;nbsp;)&lt;/nowiki&gt; |ftype1 = table, function/nil, boolean/nil |fuse1 = Loops...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.geministation.com/index.php?title=Module:Enum/doc&amp;diff=8876&amp;oldid=prev"/>
		<updated>2021-03-24T01:55:04Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;{{Documentation}} {{Helper module |name = Enum  |fname1 = &amp;lt;nowiki&amp;gt;all( enum, [fn], [clone|false] )&amp;lt;/nowiki&amp;gt; |ftype1 = table, function/nil, boolean/nil |fuse1 = Loops...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{Documentation}}&lt;br /&gt;
{{Helper module&lt;br /&gt;
|name = Enum&lt;br /&gt;
&lt;br /&gt;
|fname1 = &amp;lt;nowiki&amp;gt;all(&amp;amp;nbsp;enum, [fn], [clone|false]&amp;amp;nbsp;)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
|ftype1 = table, function/nil, boolean/nil&lt;br /&gt;
|fuse1 = Loops over the array part of &amp;lt;code&amp;gt;enum&amp;lt;/code&amp;gt; and passes each element as the first argument to &amp;lt;code&amp;gt;fn&amp;lt;/code&amp;gt;. If &amp;lt;code&amp;gt;fn&amp;lt;/code&amp;gt; returns &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt; for all elements then &amp;lt;code&amp;gt;all()&amp;lt;/code&amp;gt; returns &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt;, otherwise &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt;. If no function is given &amp;lt;code&amp;gt;function(&amp;amp;nbsp;item&amp;amp;nbsp;) return item end&amp;lt;/code&amp;gt; is used.&lt;br /&gt;
&lt;br /&gt;
|fname2 = &amp;lt;nowiki&amp;gt;any(&amp;amp;nbsp;enum, [fn], [clone|false]&amp;amp;nbsp;)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
|ftype2 = table, function/nil, boolean/nil&lt;br /&gt;
|fuse2 = Loops over the array part of &amp;lt;code&amp;gt;enum&amp;lt;/code&amp;gt; and passes each element as the first argument to &amp;lt;code&amp;gt;fn&amp;lt;/code&amp;gt;. If &amp;lt;code&amp;gt;fn&amp;lt;/code&amp;gt; returns &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt; for at least one element then &amp;lt;code&amp;gt;any()&amp;lt;/code&amp;gt; returns &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt;, otherwise &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt;. If no function is given &amp;lt;code&amp;gt;function(&amp;amp;nbsp;item&amp;amp;nbsp;) return item end&amp;lt;/code&amp;gt; is used. If &amp;lt;code&amp;gt;clone&amp;lt;/code&amp;gt; is &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt; the input &amp;lt;code&amp;gt;enum&amp;lt;/code&amp;gt; is deep copied using &amp;lt;code&amp;gt;mw.clone()&amp;lt;/code&amp;gt; before use.&lt;br /&gt;
&lt;br /&gt;
|fname3 = &amp;lt;nowiki&amp;gt;contains(&amp;amp;nbsp;enum, elem, [clone|false]&amp;amp;nbsp;)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
|ftype3 = table, any, boolean/nil&lt;br /&gt;
|fuse3 = Returns &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt; if &amp;lt;code&amp;gt;enum&amp;lt;/code&amp;gt; contains &amp;lt;code&amp;gt;elem&amp;lt;/code&amp;gt;, otherwise returns false.&lt;br /&gt;
&lt;br /&gt;
|fname4 = &amp;lt;nowiki&amp;gt;each(&amp;amp;nbsp;enum, fn, [clone|false]&amp;amp;nbsp;)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
|ftype4 = table, function, boolean/nil&lt;br /&gt;
|fuse4 = Loops over the array part of &amp;lt;code&amp;gt;enum&amp;lt;/code&amp;gt; and passes each element as the first argument to &amp;lt;code&amp;gt;fn&amp;lt;/code&amp;gt;. This function returns nothing.&lt;br /&gt;
&lt;br /&gt;
|fname5 = &amp;lt;nowiki&amp;gt;filter(&amp;amp;nbsp;enum, [fn], [clone|false]&amp;amp;nbsp;)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
|ftype5 = table, function/nil, boolean/nil&lt;br /&gt;
|fuse5 = Loops over the array part of &amp;lt;code&amp;gt;enum&amp;lt;/code&amp;gt; and passes each element as the first argument to &amp;lt;code&amp;gt;fn&amp;lt;/code&amp;gt;. If &amp;lt;code&amp;gt;fn&amp;lt;/code&amp;gt; returns &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt; the corresponding element is copied to a new table which is then returned. If no function is given &amp;lt;code&amp;gt;function(&amp;amp;nbsp;item&amp;amp;nbsp;) return item end&amp;lt;/code&amp;gt; is used.&lt;br /&gt;
&lt;br /&gt;
|fname6 = &amp;lt;nowiki&amp;gt;find(&amp;amp;nbsp;enum, fn, [default|nil], [clone|false]&amp;amp;nbsp;)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
|ftype6 = table, function, any, boolean/nil&lt;br /&gt;
|fuse6 = Loops over the array part of &amp;lt;code&amp;gt;enum&amp;lt;/code&amp;gt; and passes each element as the first argument to &amp;lt;code&amp;gt;fn&amp;lt;/code&amp;gt;. The first element where &amp;lt;code&amp;gt;fn&amp;lt;/code&amp;gt; returns &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt; is returned. If no elements passes the test, &amp;lt;code&amp;gt;default&amp;lt;/code&amp;gt; is returned.&lt;br /&gt;
&lt;br /&gt;
|fname7 = &amp;lt;nowiki&amp;gt;find_index(&amp;amp;nbsp;enum, fn, [default|nil], [clone|false]&amp;amp;nbsp;)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
|ftype7 = table, function, any, boolean/nil&lt;br /&gt;
|fuse7 = Loops over the array part of &amp;lt;code&amp;gt;enum&amp;lt;/code&amp;gt; and passes each element as the first argument to &amp;lt;code&amp;gt;fn&amp;lt;/code&amp;gt;. The index of the first element where &amp;lt;code&amp;gt;fn&amp;lt;/code&amp;gt; returns &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt; is returned. If no elements passes the test, &amp;lt;code&amp;gt;default&amp;lt;/code&amp;gt; is returned.&lt;br /&gt;
&lt;br /&gt;
|fname8 = &amp;lt;nowiki&amp;gt;insert(&amp;amp;nbsp;enum1, enum2, [index|#enum1+1], [clone|false]&amp;amp;nbsp;)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
|ftype8 = table, table, number, boolean/nil&lt;br /&gt;
|fuse8 = Returns a new table with &amp;lt;code&amp;gt;enum2&amp;lt;/code&amp;gt; inserted into &amp;lt;code&amp;gt;enum1&amp;lt;/code&amp;gt; at index &amp;lt;code&amp;gt;index&amp;lt;/code&amp;gt;. If no index is given, &amp;lt;code&amp;gt;enum2&amp;lt;/code&amp;gt; is appended to &amp;lt;code&amp;gt;enum1&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
|fname9 = &amp;lt;nowiki&amp;gt;intersect(&amp;amp;nbsp;enum1, enum2, [clone|false]&amp;amp;nbsp;)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
|ftype9 = table, table, boolean/nil&lt;br /&gt;
|fuse9 = Returns a table containing elements which exist in both enums. The order of the elements is the same as the order they occure in &amp;lt;code&amp;gt;enum1&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
|fname10 = &amp;lt;nowiki&amp;gt;intersects(&amp;amp;nbsp;enum1, enum2, [clone|false]&amp;amp;nbsp;)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
|ftype10 = table, table, boolean/nil&lt;br /&gt;
|fuse10 = Returns &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt; if both sets have at least one element with equal values.&lt;br /&gt;
&lt;br /&gt;
|fname11 = &amp;lt;nowiki&amp;gt;map(&amp;amp;nbsp;enum, fn, [clone|false]&amp;amp;nbsp;)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
|ftype11 = table, function, boolean/nil&lt;br /&gt;
|fuse11 = Loops over the array part of &amp;lt;code&amp;gt;enum&amp;lt;/code&amp;gt; and passes each element as the first argument to &amp;lt;code&amp;gt;fn&amp;lt;/code&amp;gt;. The return value of &amp;lt;code&amp;gt;fn&amp;lt;/code&amp;gt; is appended to a new table. This new table is returned.&lt;br /&gt;
&lt;br /&gt;
|fname12 = &amp;lt;nowiki&amp;gt;max_by(&amp;amp;nbsp;enum, fn, [clone|false]&amp;amp;nbsp;)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
|ftype12 = table, function, boolean/nil&lt;br /&gt;
|fuse12 = Loops over the array part of &amp;lt;code&amp;gt;enum&amp;lt;/code&amp;gt; and passes each element as the first argument to &amp;lt;code&amp;gt;fn&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;max_by()&amp;lt;/code&amp;gt; returns two values, the first is the element where &amp;lt;code&amp;gt;fn&amp;lt;/code&amp;gt; returned the largest value, the second is this largest value. The &amp;lt;code&amp;gt;&amp;gt;&amp;lt;/code&amp;gt; operator is used for the comparisons.&lt;br /&gt;
&lt;br /&gt;
|fname13 = &amp;lt;nowiki&amp;gt;new(&amp;amp;nbsp;[enum|{}]&amp;amp;nbsp;)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
|ftype13 = table&lt;br /&gt;
|fuse13 = Adds a metatable to &amp;lt;samp&amp;gt;enum&amp;lt;/samp&amp;gt; which allows it use elementwise math operations on the table. Also makes it possible to use the colon : operator with all the other functions listed here that take a table as their first argument.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;#039;lua&amp;#039;&amp;gt;&lt;br /&gt;
local t = enum.new{1, 2, 3}&lt;br /&gt;
local t2 = enum{4, 5, 6} -- Alternative notation&lt;br /&gt;
&lt;br /&gt;
mw.log( -t ) --&amp;gt; { -1, -2, -3 }&lt;br /&gt;
mw.log( t + 2 ) --&amp;gt; { 3, 4, 5 }&lt;br /&gt;
mw.log( t - 2 ) --&amp;gt; { -1, 0, 1 }&lt;br /&gt;
mw.log( t * 2 ) --&amp;gt; { 2, 4, 6 }&lt;br /&gt;
mw.log( t / 2 ) --&amp;gt; { 0.5, 1, 1.5 }&lt;br /&gt;
mw.log( t ^ 2 ) --&amp;gt; { 1, 4, 9 }&lt;br /&gt;
&lt;br /&gt;
mw.log( t + t2 ) --&amp;gt; { 5, 7, 9 }&lt;br /&gt;
mw.log( t .. t2 ) --&amp;gt; { 1, 2, 3, 4, 5, 6 }&lt;br /&gt;
mw.log( t:sum() ) --&amp;gt; 6&lt;br /&gt;
mw.log( (t .. t2):reject{3, 4, 5} ) --&amp;gt; { 1, 2, 6 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|fname14 = &amp;lt;nowiki&amp;gt;newIncrementor(&amp;amp;nbsp;[start|1], [step|1]&amp;amp;nbsp;)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
|ftype14 = number, number&lt;br /&gt;
|fuse14 = Returns a new incrementor function. Every time this incrementor function is called it returns a number &amp;lt;code&amp;gt;step&amp;lt;/code&amp;gt; higher than the previous call. The current value can be obtained with &amp;lt;code&amp;gt;inc.n&amp;lt;/code&amp;gt; or set &amp;lt;code&amp;gt;inc.n = number&amp;lt;/code&amp;gt; where &amp;lt;code&amp;gt;inc&amp;lt;/code&amp;gt; is an incrementor function. The step size can be changed with &amp;lt;code&amp;gt;inc.step = number&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
|fname15 = &amp;lt;nowiki&amp;gt;range(&amp;amp;nbsp;stop&amp;amp;nbsp;)&amp;lt;/nowiki&amp;gt;;;&lt;br /&gt;
&amp;lt;nowiki&amp;gt;range(&amp;amp;nbsp;start, stop, [step|1]&amp;amp;nbsp;)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
|ftype15 = number, number, number&lt;br /&gt;
|fuse15 = Returns a table containing a sequence of numbers from &amp;lt;code&amp;gt;start&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;stop&amp;lt;/code&amp;gt; (both inclusive if ints, end-exclusive if floats) by &amp;lt;code&amp;gt;step&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;range(4)&amp;lt;/code&amp;gt; produces &amp;lt;code&amp;gt;{1, 2, 3, 4}&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;start&amp;lt;/code&amp;gt; defaults to &amp;lt;code&amp;gt;1&amp;lt;/code&amp;gt;). &amp;lt;code&amp;gt;range(0, 4)&amp;lt;/code&amp;gt; produces &amp;lt;code&amp;gt;{0, 1, 2, 3, 4}&amp;lt;/code&amp;gt;. When &amp;lt;code&amp;gt;step&amp;lt;/code&amp;gt; is given, it specifies the increment (or decrement).&lt;br /&gt;
&lt;br /&gt;
|fname16 = &amp;lt;nowiki&amp;gt;reduce(&amp;amp;nbsp;enum, fn, [accumulator|enum[1]], [clone|false]&amp;amp;nbsp;)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
|ftype16 = table, function, any, boolean/nil&lt;br /&gt;
|fuse16 = Loops over the array part of &amp;lt;code&amp;gt;enum&amp;lt;/code&amp;gt; and passes each element as the first argument and &amp;lt;code&amp;gt;accumulator&amp;lt;/code&amp;gt; as the second to &amp;lt;code&amp;gt;fn&amp;lt;/code&amp;gt;. The return value of &amp;lt;code&amp;gt;fn&amp;lt;/code&amp;gt; becomes the new &amp;lt;code&amp;gt;accumulator&amp;lt;/code&amp;gt;. The final value of &amp;lt;code&amp;gt;accumulator&amp;lt;/code&amp;gt; is returned. If no &amp;lt;code&amp;gt;accumulator&amp;lt;/code&amp;gt; is given then the first element in &amp;lt;code&amp;gt;enum&amp;lt;/code&amp;gt; is used.&lt;br /&gt;
&lt;br /&gt;
|fname17 = &amp;lt;nowiki&amp;gt;reject(&amp;amp;nbsp;enum, [fn], [clone|false]&amp;amp;nbsp;)&amp;lt;/nowiki&amp;gt;;;&lt;br /&gt;
&amp;lt;nowiki&amp;gt;reject(&amp;amp;nbsp;enum, [table], [clone|false]&amp;amp;nbsp;)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
|ftype17 = table, function/table, boolean/nil&lt;br /&gt;
|fuse17 = The opposite of &amp;lt;code&amp;gt;filter()&amp;lt;/code&amp;gt;. If the second argument is a table, every element in &amp;lt;code&amp;gt;enum&amp;lt;/code&amp;gt; equal to any of the values in this table will be rejected.&lt;br /&gt;
&lt;br /&gt;
|fname18 = &amp;lt;nowiki&amp;gt;rep(&amp;amp;nbsp;val, n, [clone|false]&amp;amp;nbsp;)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
|ftype18 = any, number, boolean&lt;br /&gt;
|fuse18 = Returns a table with &amp;lt;samp&amp;gt;n&amp;lt;/samp&amp;gt; copies of &amp;lt;samp&amp;gt;val&amp;lt;/samp&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
|fname19 = &amp;lt;nowiki&amp;gt;scan(&amp;amp;nbsp;enum, fn, [accumulator|enum[1]], [clone|false]&amp;amp;nbsp;)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
|ftype19 = table, function, any, boolean/nil&lt;br /&gt;
|fuse19 = Same as &amp;lt;code&amp;gt;reduce()&amp;lt;/code&amp;gt; but each step is appended to a table. This table is then returned.&lt;br /&gt;
&lt;br /&gt;
|fname20 = &amp;lt;nowiki&amp;gt;slice(&amp;amp;nbsp;enum, [start|1], [stop|#enum], [clone|false]&amp;amp;nbsp;)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
|ftype20 = table, number/nil, number/nil, boolean/nil&lt;br /&gt;
|fuse20 = Returns a table containing all the elements of &amp;lt;code&amp;gt;enum&amp;lt;/code&amp;gt; between the &amp;lt;code&amp;gt;start&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;stop&amp;lt;/code&amp;gt; indices. The &amp;lt;code&amp;gt;start&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;stop&amp;lt;/code&amp;gt; indices are inclusive.&lt;br /&gt;
&lt;br /&gt;
|fname21 = &amp;lt;nowiki&amp;gt;split(&amp;amp;nbsp;enum, count, [clone|false]&amp;amp;nbsp;)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
|ftype21 = table, number, boolean/nil&lt;br /&gt;
|fuse21 = Returns two tables where the first is equivalent to &amp;lt;code&amp;gt;slice(&amp;amp;nbsp;enum, 1, count&amp;amp;nbsp;)&amp;lt;/code&amp;gt; and the second &amp;lt;code&amp;gt;slice(&amp;amp;nbsp;enum, count+1, #enum&amp;amp;nbsp;)&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
|fname22 = &amp;lt;nowiki&amp;gt;sum(&amp;amp;nbsp;enum, [clone|false]&amp;amp;nbsp;)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
|ftype22 = table, boolean/nil&lt;br /&gt;
|fuse22 = Returns the sum of all array elements in &amp;lt;code&amp;gt;enum&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
|fname23 = &amp;lt;nowiki&amp;gt;take(&amp;amp;nbsp;enum, count, [clone|false]&amp;amp;nbsp;)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
|ftype23 = table, number, boolean/nil&lt;br /&gt;
|fuse23 = Returns only the first table of &amp;lt;code&amp;gt;split(&amp;amp;nbsp;enum, count&amp;amp;nbsp;)&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
|fname24 = &amp;lt;nowiki&amp;gt;take_every(&amp;amp;nbsp;enum, n, [clone|false]&amp;amp;nbsp;)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
|ftype24 = table, number, boolean/nil&lt;br /&gt;
|fuse24 = Returns a table containing every nth element of &amp;lt;code&amp;gt;enum&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
|fname25 = &amp;lt;nowiki&amp;gt;unique(&amp;amp;nbsp;enum, [fn], [clone|false]&amp;amp;nbsp;)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
|ftype25 = table, function/nil, boolean/nil&lt;br /&gt;
|fuse25 = Returns a new table where all duplicate values in &amp;lt;code&amp;gt;enum&amp;lt;/code&amp;gt; are removed. In case a duplicate is present, the element with the lowest index will be kept and every subsequent duplicate element is removed. &amp;lt;code&amp;gt;fn&amp;lt;/code&amp;gt; can be used to create a custom id for every element so that the result is a table with elements which all create a unique id. If no function is given &amp;lt;code&amp;gt;function(&amp;amp;nbsp;item&amp;amp;nbsp;) return item end&amp;lt;/code&amp;gt; is used.&lt;br /&gt;
&lt;br /&gt;
|fname26 = &amp;lt;nowiki&amp;gt;zip(&amp;amp;nbsp;enums, [clone|false]&amp;amp;nbsp;)&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
|ftype26 = table, boolean/nil&lt;br /&gt;
|fuse26 = Groups elements with the same indexes from different arrays together, i.e. &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;zip{ {a1, a2, a3}, {b1, b2, b3}, {c1, c2} } -&amp;gt; {{a1, b1, c1}, {a2, b2, c2}, {a3, b3}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|example =&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;#039;lua&amp;#039;&amp;gt;&lt;br /&gt;
local enum = require( &amp;#039;Module:Enum&amp;#039; )&lt;br /&gt;
&lt;br /&gt;
local seqOne = {1, 2, 3, 4, 10}&lt;br /&gt;
local seqTwo = {&amp;#039;a&amp;#039;, &amp;#039;b&amp;#039;, &amp;#039;b&amp;#039;, 1}&lt;br /&gt;
local seqThree = {}&lt;br /&gt;
local var, var2&lt;br /&gt;
&lt;br /&gt;
enum.any( seqOne, function( item ) return item == 3 end ) --&amp;gt; true&lt;br /&gt;
enum.all( seqTwo, function( item ) return type( item ) == &amp;#039;string&amp;#039; end ) --&amp;gt; false&lt;br /&gt;
enum.each( seqOne, function( item ) table.insert( seqThree, item * 2 ) end ) --&amp;gt; seqThree = {2, 4, 6, 8, 20}&lt;br /&gt;
seqThree = enum.map( seqOne, function( item ) return item * 2 end ) --&amp;gt; seqThree = {2, 4, 6, 8, 20}&lt;br /&gt;
seqThree = enum.filter( seqTwo, function( item ) return type( item ) == &amp;#039;string&amp;#039; end ) --&amp;gt; seqThree = {&amp;#039;a&amp;#039;, &amp;#039;b&amp;#039;, &amp;#039;b&amp;#039;}&lt;br /&gt;
seqThree = enum.reject( seqTwo, function( item ) return type( item ) == &amp;#039;string&amp;#039; end ) --&amp;gt; seqThree = {1}&lt;br /&gt;
var = enum.find( seqOne, function( item ) return item &amp;gt; 5 end ) --&amp;gt; var = 10&lt;br /&gt;
var = enum.find_index( seqTwo, function( item ) return type( item ) ~= &amp;#039;string&amp;#039; end ) --&amp;gt; var = 4&lt;br /&gt;
var, var2 = enum.max_by( seqOne, function( item ) return (item % 10) * item end ) --&amp;gt; var = 4, var2 = 16&lt;br /&gt;
var = enum.reduce( seqOne, function( item, acc ) return acc + item*item end, 5 ) --&amp;gt; var = 135&lt;br /&gt;
var = enum.range( 10, 1, -3 ) --&amp;gt; var = {10, 7, 4, 1}&lt;br /&gt;
seqThree = enum.scan( seqOne, function( item, acc ) return acc + item*item end, 5 ) --&amp;gt; seqThree = {6, 10, 19, 35, 135}&lt;br /&gt;
seqThree = enum.slice( seqOne, 2, 4 ) --&amp;gt; seqThree = {2, 3, 4}&lt;br /&gt;
var, var2 = enum.split( seqOne, 2 ) --&amp;gt; var = {1, 2}, var2 = {3, 4, 10}&lt;br /&gt;
var = enum.sum( seqOne ) --&amp;gt; var = 20&lt;br /&gt;
seqThree = enum.take( seqOne, 2 ) --&amp;gt; seqThree = {1, 2}&lt;br /&gt;
seqThree = enum.take_every( seqOne, 2 ) --&amp;gt; seqThree = {1, 3, 10}&lt;br /&gt;
seqThree = enum.unique( seqTwo ) --&amp;gt; seqThree = {&amp;#039;a&amp;#039;, &amp;#039;b&amp;#039;, 1}&lt;br /&gt;
seqThree = enum.zip( {seqOne, seqTwo, {20, 30}} ) --&amp;gt; seqThree = {{1, &amp;#039;a&amp;#039;, 20}, {2, &amp;#039;b&amp;#039;, 30}, {3, &amp;#039;b&amp;#039;}, {4, 1}, {10}}&lt;br /&gt;
seqThree = enum.insert( seqOne, seqTwo, 3 ) --&amp;gt; seqThree = {1, 2, &amp;#039;a&amp;#039;, &amp;#039;b&amp;#039;, &amp;#039;b&amp;#039;, 1, 3, 4, 10}&lt;br /&gt;
seqThree = enum.intersect( seqOne, seqTwo ) --&amp;gt; seqThree = {1}&lt;br /&gt;
var = enum.intersects( seqOne, seqTwo ) --&amp;gt; var = true&lt;br /&gt;
cond = enum.contains({ 1, 2, 3}, 3) --&amp;gt; cond = true&lt;br /&gt;
&lt;br /&gt;
inc = enum.newIncrementor( 10, 5 )&lt;br /&gt;
print( inc() ) --&amp;gt; 10&lt;br /&gt;
print( inc() ) --&amp;gt; 15&lt;br /&gt;
&lt;br /&gt;
-- Reason to use clone:&lt;br /&gt;
seqOne = {{1}, {2}}&lt;br /&gt;
seqTwo = enum.slice( seqOne, 2, 2 ) --&amp;gt; seqTwo = {{2}}&lt;br /&gt;
seqTwo[1][1] = 5&lt;br /&gt;
mw.log( seqOne[2][1] ) --&amp;gt; 5, The value in seqOne also got changed&lt;br /&gt;
&lt;br /&gt;
seqOne = {{1}, {2}}&lt;br /&gt;
seqThree = enum.slice( seqOne, 2, 2, true ) --&amp;gt; seqThree = {{2}}&lt;br /&gt;
seqThree[1][1] = 5&lt;br /&gt;
mw.log( seqOne[2][1] ) --&amp;gt; 2, The value in seqOne is unchanged&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;/div&gt;</summary>
		<author><name>Banri</name></author>
	</entry>
</feed>