title: Lua iterator to array
body: <p>In Lua parlance, is there any syntactic sugar for turning an iterator function into an array (repeated invocations with results stored in ascending indices), perhaps something in the standard library ? </p>
  
  <p>I'm tokenizing a string belonging to a protocol and need to to have positional access to elements at the start of the string, and the end of the string is a variant collection.</p>
  
  <p>The code (specific to my use-case) is as follows, I find it hard to believe that it isn't in the standard library :d </p>
  
  <pre><code>local array_tokenise = function (line)
      local i = 1;
      local array = {};
  
      for item in string.gmatch(line,"%w+") do
        array[i] = item;
        i = i +1
      end
  
      return array
    end
  </code></pre>