Hi Niko,
running this in zerobrane gives two instances for the iterator returned by
fromto as if it were a closure, however doing the same on the command line
(lua 5.2 OS-X) works as expected, i.e. single instance for the function (and
two different tables). What am I missing?
Dear all,
Please forgive what is for sure a total newbie question: I am going through
the the LUA course using zero-brane and I remarked that when I play with
stateless iterators like so
function fromto(a, b)
return function (state)
if state[1] > state[2] then
return nil
else
state[1] = state[1] + 1
return state[1] - 1
end
end, { a, b }
end
print(fromto(2, 5))
print(fromto(4, 7))
running this in zerobrane gives two instances for the iterator returned by
fromto as if it were a closure, however doing the same on the command line
(lua 5.2 OS-X) works as expected, i.e. single instance for the function (and
two different tables). What am I missing?
Many thanks,