Difference between revisions of "sequence"

(Created page with "From the Lua 5.2 [http://www.lua.org/manual/5.2/manual.html reference manual]: We use the term sequence to denote a table where the set of all positive numeric keys is equal...")
 
(Add example without explicit indices)
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
From the Lua 5.2 [http://www.lua.org/manual/5.2/manual.html reference manual]:
+
From the Lua 5.2 [http://www.lua.org/manual/5.2/manual.html#2.1 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 [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 = { 'foo', 'bar', 'baz', 'qux', --[[ ... ]] }
 +
 +
-- or
 +
 +
sequence = {
 +
    [1] = 'foo',
 +
    [2] = 'bar',
 +
    [3] = 'baz',
 +
    [4] = 'qux',
 +
    -- [n] = ...,
 +
}
 +
</source>
 +
 +
[[Category:Lua]]
 +
== Other Languages ==
 +
{{i18n|sequence}}

Latest revision as of 15:28, 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 = { 'foo', 'bar', 'baz', 'qux', --[[ ... ]] }

-- or

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

Other Languages