Difference between revisions of "sequence"

m
m (Add example.)
Line 2: Line 2:
  
 
We use the term sequence to denote a [[table]] where the set of all positive numeric keys is equal to {1..n} for some integer n, which is called the length of the sequence (see [http://www.lua.org/manual/5.2/manual.html#3.4.6 §3.4.6]).
 
We use the term sequence to denote a [[table]] where the set of all positive numeric keys is equal to {1..n} for some integer n, which is called the length of the sequence (see [http://www.lua.org/manual/5.2/manual.html#3.4.6 §3.4.6]).
 +
 +
<source lang='lua'>
 +
sequence = {
 +
    [1] = 'foo',
 +
    [2] = 'bar',
 +
    [3] = 'baz',
 +
    [4] = 'qux',
 +
    -- [n] = ...,
 +
}
 +
</source>
  
 
[[Category:Lua]]
 
[[Category:Lua]]
 
== Other Languages ==
 
== Other Languages ==
 
{{i18n|sequence}}
 
{{i18n|sequence}}

Revision as of 08:50, 28 January 2015

From the Lua 5.2 reference manual §2.1:

We use the term sequence to denote a table where the set of all positive numeric keys is equal to {1..n} for some integer n, which is called the length of the sequence (see §3.4.6).

sequence = {
    [1] = 'foo',
    [2] = 'bar',
    [3] = 'baz',
    [4] = 'qux',
    -- [n] = ...,
}

Other Languages