304 bytes added
, 7 years ago
local Iterator = {}
function Iterator.array(arr, i, n)
i = i or 0
n = n and math.min(#arr, n) or #arr
function step(n, i)
if i < n then
i = i + 1
return i, arr[i]
end
end
return function()
return step, n, i
end
end
return Iterator