lua反復器の例
369 ワード
function iter(t)
local i = 0
local n = table.getn(t)
return function ()
i = i + 1
if(i <=n ) then
return t[i]
else
return nil
end
end
end
ar = {1, 2, 3}
ariter = iter(ar)
while true do
local e = ariter()
if(e == nil) then
break
end
print(e)
end