function integer_iterator(a, b)
local n = a - 1
return function()
n = n + 1
if (n > b) then return nil
else return n
end
end
end
for n in integer_iterator(10, 15) do
print(n)
end
Sunday, May 13, 2012
Lua의 closure를 이용한 iterator 구현 예
Labels:
Lua
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment